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.
Syncfusion Feedback

SourceListListChanged event

Thread ID:

Created:

Updated:

Platform:

Replies:

21566 Nov 15,2004 09:10 AM UTC Nov 15,2004 04:36 PM UTC Windows Forms 5
loading
Tags: Grouping
Dominic Morris
Asked On November 15, 2004 09:10 AM UTC

Hi, I''m updating the cells in a column of my groupingdatagrid by changing the values in the underlying DataTable. That works fine, but I''d like to add some fn''ality to colour the cells according to whether they''ve changed up or down, numerically. I''d like to do this generically. So I need a class that detects changes in the underlying DataTable, and responds accordingly. The problem I''m hitting is that the event that I''m using to detect these changes (SourceListListChanged) only seems to tell me which row in the underlying IList has changed: void ggc_SourceListListChanged( object sender, TableListChangedEventArgs e ) { IListSource ils = ggc.DataSource as IListSource; if( ils != null ) { IList il = ils.GetList(); System.Diagnostics.Debug.WriteLine( "ggc_SourceListListChanged" ); System.Diagnostics.Debug.WriteLine( " ListChangedType: " + e.ListChangedType.ToString() ); System.Diagnostics.Debug.WriteLine( " OldIndex: " + e.OldIndex );//+ " [" + il[e.OldIndex].ToString() + "]" ); System.Diagnostics.Debug.WriteLine( " NewIndex: " + e.NewIndex + " [" + il[e.NewIndex].ToString() + "]" ); DataRowView drv = il[e.NewIndex]; } } Making no reference to the column that has changed. Furthermote, I need a way of going from the changed DataRowView object to an absolute x,y cell reference within the grid, so that my rendering code can determine which cells to draw specially. So: a) how can I tell when a specific column in a DataRowView has changed? b) how can I map a DataRowView and column index into a GridTableControlDrawCellEventArgs.Inner.RowIndex / GridTableControlDrawCellEventArgs.Inner.ColIndex pair, so that I can render a specific cell differently? Many thanks, DM

Dominic Morris
Replied On November 15, 2004 11:21 AM UTC

Related to this: I would like to re-draw a single cell (on a timer). What''s the best way to accomplish this?

Administrator [Syncfusion]
Replied On November 15, 2004 11:48 AM UTC

If you are using a DataTable datasource, a simpler way to do this is to handle TableControlPrepareViewStyleInfo and compare the current value of the record field to the orginal value (which you can get from the DataRow), and then color it if they are different.
private void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
	GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex];
	if((style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell 
		|| style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
		&& style.TableCellIdentity.DisplayElement != null)
	{
		DataRowView drv = style.TableCellIdentity.DisplayElement.GetData() as DataRowView;
		if(drv != null && !drv.Row[style.TableCellIdentity.Column.Name, DataRowVersion.Original].Equals(style.CellValue))
		{
			//Console.WriteLine("******" + drv[style.TableCellIdentity.Column.Name]);
			e.Inner.Style.BackColor = Color.Red;
		}
	}
}

Dominic Morris
Replied On November 15, 2004 11:56 AM UTC

Cool, looks good. Will try it now. Thanks Clay.

Dominic Morris
Replied On November 15, 2004 12:37 PM UTC

Clay, I get the error: "There is no Original data to access." when I try this code. Google shows this to be an error associated with much confusion & despair. :(

Administrator [Syncfusion]
Replied On November 15, 2004 04:36 PM UTC

After loading your DataTable, are you calling DataTable.AcceptChanges to set the row state of the DataTable?

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.

Warning Icon 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.Close Icon

;