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.
Unfortunately, activation email could not send to your email. Please try again.

Grid List control

Thread ID:

Created:

Updated:

Platform:

Replies:

70259 Dec 4,2007 01:01 PM Dec 4,2007 04:23 PM Windows Forms 1
loading
Tags: GridControl
Stuck_in_code
Asked On December 4, 2007 01:01 PM

I am using 2 gridlist controls in my project. There is a requirement that as soon as I select a code in the first gridlist control, it should be added to the first position in the second gridlist and the color of text in that first/top row should be different from the default color of other rows.
Thus, if I add one more record to the second gridlist control, this particular record should be shown in different color and the rest of the records should be shown in defualt color.
Is this possible in GridList control and if so then how?

SA


haneefm [Syncfusion]
Replied On December 4, 2007 04:23 PM

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.zip

Best regards,
Haneef


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;