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. Change of text color in PropertyGrid

Change of text color in PropertyGrid

Scheduled Pinned Locked Moved Windows Forms
question
4 Posts 2 Posters 0 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.
  • M Offline
    M Offline
    Member 1330121
    wrote on last edited by
    #1

    Hello, I am using propertyGrid window to display name and its value. I allow the user to enter value and if he enters a wrong value (there is a seperate code to validate), then I am supposed to display the user entered text value in red color (text in red color) or the back ground color of that particular cell alone (not the entire propertyGrid window) in red color. Is this posssible using PropertyGrid? I can understand that the color of entire propertyGrid can be changed, but I am looking for changing single cell's either the text color or the background color of the particular cell to red. Thanks in advance

    D 1 Reply Last reply
    0
    • M Member 1330121

      Hello, I am using propertyGrid window to display name and its value. I allow the user to enter value and if he enters a wrong value (there is a seperate code to validate), then I am supposed to display the user entered text value in red color (text in red color) or the back ground color of that particular cell alone (not the entire propertyGrid window) in red color. Is this posssible using PropertyGrid? I can understand that the color of entire propertyGrid can be changed, but I am looking for changing single cell's either the text color or the background color of the particular cell to red. Thanks in advance

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

      The ProeprtyGrid cannot change the color of individual cells. How each cell is rendered, including color, is left up to the UITypeEditor for each property. You'd have to create a new UITypeEditor for each of the properties that you want to be able to render in a different color. Documentation on User Interface Type Editors[^].

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008
      But no longer in 2009...

      M 1 Reply Last reply
      0
      • D Dave Kreskowiak

        The ProeprtyGrid cannot change the color of individual cells. How each cell is rendered, including color, is left up to the UITypeEditor for each property. You'd have to create a new UITypeEditor for each of the properties that you want to be able to render in a different color. Documentation on User Interface Type Editors[^].

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008
        But no longer in 2009...

        M Offline
        M Offline
        Member 1330121
        wrote on last edited by
        #3

        I tried using UITypeEditor which allows me to paint the cell, but it also displays a small recangular box in the cell, which makes my display look ugly. Can you tell me how to get rid of this small rectangle? The rectangular box appears as soon as I override the following function of UIEditorType public override bool GetPaintValueSupported(ITypeDescriptorContext context) { //Set to true to implement the PaintValue method return true; } I tried clearing the cell in PaintValue method but that did not work public override void PaintValue(PaintValueEventArgs e) { base.PaintValue(e); Region reg = new Region(new Rectangle(e.Bounds.X , e.Bounds.Y, e.Bounds.Width+10 , e.Bounds.Height)); Region tempReg = e.Graphics.Clip; e.Graphics.Clip = reg; // Tried to clear the entire cell with white color but still the small rectangle appears e.Graphics.Clear(Color.White); e.Graphics.Clip = tempReg; // Fill region also did not work //e.Graphics.FillRegion(Brushes.Red, reg); } }

        D 1 Reply Last reply
        0
        • M Member 1330121

          I tried using UITypeEditor which allows me to paint the cell, but it also displays a small recangular box in the cell, which makes my display look ugly. Can you tell me how to get rid of this small rectangle? The rectangular box appears as soon as I override the following function of UIEditorType public override bool GetPaintValueSupported(ITypeDescriptorContext context) { //Set to true to implement the PaintValue method return true; } I tried clearing the cell in PaintValue method but that did not work public override void PaintValue(PaintValueEventArgs e) { base.PaintValue(e); Region reg = new Region(new Rectangle(e.Bounds.X , e.Bounds.Y, e.Bounds.Width+10 , e.Bounds.Height)); Region tempReg = e.Graphics.Clip; e.Graphics.Clip = reg; // Tried to clear the entire cell with white color but still the small rectangle appears e.Graphics.Clear(Color.White); e.Graphics.Clip = tempReg; // Fill region also did not work //e.Graphics.FillRegion(Brushes.Red, reg); } }

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

          Since I can't see the "small rectangle" you're talking about, no I can't tell you how to get rid of it. Perhaps a screen shot would help??

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008
          But no longer in 2009...

          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