Hi,
You can acheive this by handling the PrepareViewStyleInfo event of the gridcontrol.
The idea is to have a hashtable and in that hastable, set the ID of the datarow in the SelectedValueChanged event and check that ID in PrepareViewStyleInfo event of another gridlistcontrol to provide the color of the row. Below are codes that shows this task.
this.gridListControl2.Grid.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);
void gridListControl1_SelectedValueChanged(object sender, EventArgs e)
{
GridListControl ListControl = sender as GridListControl;
DataRowView dr = ListControl.SelectedValue as DataRowView;
if ( !prevHashtable.Contains(dr[0]))
{
prevHashtable.Add(dr[0]);
DataTable dt = this.gridListControl2.DataSource as DataTable;
DataRow drow = dt.NewRow();
drow.ItemArray = dr.Row.ItemArray;
dt.Rows.InsertAt(drow, 0);
this.gridListControl2.Grid.ResetVolatileData();
this.gridListControl2.Refresh();
}
}
void Grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex > 0 && e.ColIndex > 0)
{
GridControl grid = sender as GridControl;
if (prevHashtable.Contains(grid.Model[e.RowIndex, 1].CellValue))
{
e.Style.BackColor = Color.Coral;
}
}
}
Please refer to the attached sample for implementation.
GridListControl.zipBest regards,
Haneef