I have a DataGridView where the background of each row is different depending on the data bound item. Though, when I select a row, I can no longer see its original background color.

To solve this, I have thought of two solutions:

I can make the selections semi-transparent, making it possible to see if two selected rows have different background colors.

Or; I can remove the selection colors entirely, and draw a border around the selected rows.

What option is easier and how can I do this?

It's a WinForm app.

Edit: I ended up with the code in my original post: https://stackoverflow.com/questions/4448945/datagridview-row-semi-transparent-selection-or-row-border-on-selection

  • This sounds like a programming issue, more than a UI issue. It requires knowledge of 'WinForm' and 'DataGridView'. I suggest you ask this on StackOverflow.
    – Bobby Jack
    Dec 15, 2010 at 11:51
  • stackoverflow.com/questions/4448945/… ;)
    – Jim Carragher
    Dec 15, 2010 at 12:03
  • IMO, you received bad advice over in that question ("post it on ui.stackexchange") because it's a programming question; you asked "What option is easier and how can I do this".
    – Bobby Jack
    Dec 15, 2010 at 12:12
  • I'm sorry for the confusion - I was thinking more in a way: "What would the end user be most comfortable with"... I misunderstood the question - apologies @Jim Carragher and others..
    – veljkoz
    Dec 15, 2010 at 12:45
  • This is a colour and indication of selection question, not a programming question. It's a good question too, so +1. Oh, and welcome to ui SE site Jim. Dec 16, 2010 at 9:01

1 Answer 1


My first reaction when I read that "the background of each row is different depending on the data bound item" was Oh no, I hope that he's talking of one or two colors at most ! :-)

Rather than solving your selection problem, I suggest that you make it a non-problem and make it go away. I would do that by adding a separate column to provide the same information that the background color is intended to represent. Not only would it be cleaner, IMO, but it would also provide the following advantages:

  • You can sort by "status" (or whatever the colored background is intended to represent)

  • If you don't have a lot of different colors, you might be able to use shapes, which is very helpful for the color blind.

  • You can combine a visual with numeric information. The following screen snapshot shows progress bars in a column, but you can use a similar approach to represent what your background color is currently trying to achieve.

    alt text

Is there a reason that you must use background color?

  • +1 for the introduction of accessibility for colour blind users. Dec 16, 2010 at 8:59
  • Thanks for your suggestion. Yes, I will probably add a new column to present the information needed.
    – Jim Carragher
    Dec 17, 2010 at 8:14
  • Well, I ended up with a semi-transparent selection color as you can see in my edit: stackoverflow.com/questions/4448945/…
    – Jim Carragher
    Dec 17, 2010 at 12:49
  • @Hisham: how did you create the interface in the screenshot?
    – Smith
    May 4, 2013 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.