cbrown-aps
asked on
detect background color in datagridview cell
I have a datagrid that has different colors on different rows based on criteria found in different sources. When I click on that datagrid, a detail form opens up. I want to detect the background color of the row that was clicked on and make my other form background the same color.
So how can I find out what the current background color is set to on a datagridview row?
Thanks!
So how can I find out what the current background color is set to on a datagridview row?
Thanks!
Hi
Try the following:
If dataGridView1.SelectedCell s.Count > 0 Then
Dim index as integer = dataGridView1.SelectedCell s(0).RowIn dex
Dim c as Color = dataGridView1.Rows(index). DefaultCel lStyle.Bac kColor
Me.BackColor = c ' for demo only
End If
Try the following:
If dataGridView1.SelectedCell
Dim index as integer = dataGridView1.SelectedCell
Dim c as Color = dataGridView1.Rows(index).
Me.BackColor = c ' for demo only
End If
ASKER
This is happening in my mouse down event. Neither of these are working for me.
Maybe if you saw how I was getting a value to pass to the child it would spark an idea...
client = DataGridView1.Item(0, rIndex).Value
Any ideas how I could get it from this approach?
Maybe if you saw how I was getting a value to pass to the child it would spark an idea...
client = DataGridView1.Item(0, rIndex).Value
Any ideas how I could get it from this approach?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The solution achieved my goal however using a different method.
Thanks for great work!
Thanks for great work!
Try this
If DataGridView1.SelectedRows
If DataGridView1.SelectedRows
'Your Code Here
'....
End If
End If