We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Selected row showing wrong color

I have a virtual grid with ListBoxSelectionMode set to MultiExtended and AllowSelection set to Row. When I use PrepareViewStyleInfo to set the selected row color to Blue, I end up with a brown row instead. If I click on another row, while the mouse button is still down the old selected row becomes blue while the new selected row has one black cell and one brown one. When the mouse button is released the old row is changed to the same color as the other unselected rows and the new selected row is brown. There seems to be some interaction between the color I''m setting in PrepareViewStyleInfo and something else the grid is doing. Any ideas on fixing this?

6 Replies

Administrator March 23, 2004 12:47 PM UTC

The grid normally indicates selections by filling a rectangle with grid.AlphaBlendSelectionColor. So, if you also color the selection by setting a BackColor in PrepareViewStyleInfo, you will see your color overdrawn with the AlphaBlendSelectionColor color. I suspect this is what you are seeing. One solution is to more or less make the AlphaBlendSelectionColor transparent so it will not affect the backcolor you are setting. You can do this with code like: grid.AlphaBlendSelectionColor Color.FromArgb(1, 0, 0, 0); This sets its alpha blend value to 1 which lets you color show through.


BC Bill Coyle March 23, 2004 02:02 PM UTC

Changing the AlphaBlendSelectionColor had no effect.


Administrator March 23, 2004 02:08 PM UTC

Can you post a sample project showing the problem, or see the problem in one of our samples?


BC Bill Coyle March 23, 2004 03:11 PM UTC

After a few changes the brown color is gone, but I''m still getting a black select color instead of the blue I specified in PrepareViewStyleInfo. Here is a test project I created that shows the problem. GridTest1_2916.zip


Administrator March 23, 2004 04:48 PM UTC

Thank you for the sample, For your grid.AllowSelections property, you have AlphaBlend turned off. This tells the grid to Invert the selections instead of trying to fill a rectangle using an alpha-blended color. This inverting is stepping on the code you have in PrepareViewStyleInfo. So, I think turning on the AlphaBlend flag in grid.AllowSelections will give you what you want.


BC Bill Coyle March 23, 2004 05:10 PM UTC

That fixed it -- thanks.

Loader.
Live Chat Icon For mobile
Up arrow icon