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