I am using a grid with a Rounded4Thick border style on a dark background. My requirements call for the background inside the border to be white, so I am setting the BackColor to Color.White. The result leaves the small white spots in the area outside the border but inside the grid's rectangle...see the attachment.
Does anyone know of a way to set the color for that area...or at least set it to transparent?
Thanks,
Darin
P.S. Sorry for the ugly image...tried a few things to make it better but had no luck.
Darin,
In order for the BackColor to not paint in that section, you would need to calculate the region of the control yourself. Fortunately, there is already a method that will calculate this region based on the border style:
this.ultraGrid1.Region = DrawUtility.CreateBorderRegion(new Rectangle(Point.Empty, this.ultraGrid1.Size), this.ultraGrid1.DisplayLayout.BorderStyle);
You just have to make sure that you refresh this region each time that the grid is resized for whatever reason (i.e. docked/anchored in a form).
-Matt
Where would be the best place to do this...within a DrawFilter? If so, any guesses what phases/elements I would need to modify?
No, this is not done with a draw filter, the Region property is on the Control class itself. You would use exactly the code that I posted, likely in the constructor and then in the SizeChanged event handler of the grid.
OK...I tried that and I still get the white corners. I did step though to insure that it was firing before the control painted. Is there another property I have to set somewhere to specify what color I want the corners to be?
That was the issue...I was setting the BorderStyle in InitializeLayout...when I fixed the order it worked fine.
Thanks for the help,
There shouldn't be any other property, but you should definitely be using that code after you set the BorderStyle on the grid. If you are definitely setting it after you set the borders to rounded, then I'm not sure what the problem is since this worked for me. It doesn't have to be before the control painted, since setting the Region should update it.