Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. datagridview cell color

datagridview cell color

Scheduled Pinned Locked Moved Windows Forms
tutorialquestionhelp
4 Posts 4 Posters 32 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jogisarge
    wrote on last edited by
    #1

    hi, can someone tell me how to change the color of a part of a string in a cell from a datagridview. for example if the text of a cell is "125/art" how can i show the "art" in red color ? i know, i can use the Richtextbox but i dont want to change the color of the complete text. thanks for your help jogi

    D L A 3 Replies Last reply
    0
    • J jogisarge

      hi, can someone tell me how to change the color of a part of a string in a cell from a datagridview. for example if the text of a cell is "125/art" how can i show the "art" in red color ? i know, i can use the Richtextbox but i dont want to change the color of the complete text. thanks for your help jogi

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You can't unless you write your own code to custom draw the cells. There is no built-in support for what you want to do. The cells in the DGV work nothing like a RichTextBox.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      1 Reply Last reply
      0
      • J jogisarge

        hi, can someone tell me how to change the color of a part of a string in a cell from a datagridview. for example if the text of a cell is "125/art" how can i show the "art" in red color ? i know, i can use the Richtextbox but i dont want to change the color of the complete text. thanks for your help jogi

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        The simple way is by creating two columns, and setting the ForeColor to red in the second column. An alternative would be painting the cell yourself, using the CellPainting[^] event.

        I are Troll :suss:

        1 Reply Last reply
        0
        • J jogisarge

          hi, can someone tell me how to change the color of a part of a string in a cell from a datagridview. for example if the text of a cell is "125/art" how can i show the "art" in red color ? i know, i can use the Richtextbox but i dont want to change the color of the complete text. thanks for your help jogi

          A Offline
          A Offline
          All Time Programming
          wrote on last edited by
          #4

          Yes, I also agree with Eddy. If you want you can make the 2 cols width (in Properties of that particular col) very small - just till what your text fixes, alos make Resizable = False & Padding (Cell style) = 0, 0, 0, 0. With this atleast you can amke min space/gap between both the cols and paint the other col or set its background/foreground color as per your choice. To set properties of a particular cool, select grid, Column Collection, and then select your col & proceed.

          Thanks & Regards,

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups