Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > How to change previous DataGrid selected item back color
 

How to change previous DataGrid selected item back color

Hi all,

I have a DataGrid. Whenever, I select a row , the selected row back color will change to blue.

When ever, I select another row, the new row selected color will also change to blue.

But how to change the previous selected row back color back to white.

Please help.

Thanks

protected void dgInfo_SelectedIndexChanged(object sender, EventArgs e)

{

selectedValue = dgInfo.SelectedIndex.ToString();

dgInfo.SelectedItem.BackColor = Color.Blue;

}

bslim  Saturday, February 24, 2007 4:31 AM

If you are using DataGrid control there is a property by which the back color changes automatically when you select a row

Just set the SelectedItemStyle property of the DataGrid to whatever style you want and you wont even need to have a SelectedIndexChange event

Hope it helps!

mr_super_genius  Saturday, February 24, 2007 5:20 AM

If you are using DataGrid control there is a property by which the back color changes automatically when you select a row

Just set the SelectedItemStyle property of the DataGrid to whatever style you want and you wont even need to have a SelectedIndexChange event

Hope it helps!

mr_super_genius  Saturday, February 24, 2007 5:20 AM

Hi,

Thanks for your solution. I got it.

bslim  Saturday, February 24, 2007 5:52 AM

You can use google to search for other answers

Custom Search

More Threads

• Full row selection on the datagrid
• Reconfigure Connection String of DataAdapter to Use App.Config
• Data Binding behavior for Access
• Datagridview does not commit changes made to DataTable in Vista
• DataGridView and Scrolling via Mouse-Wheel
• Generated DataBinding and ComboBox Problem
• Binding an ArrayList to a DataGridView
• Merging a data table with another data table.
• Locking cells in Datagridview
• DataGrid sort