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.

SavedCellsInfo empty in CellsChanged method

Thread ID:

Created:

Updated:

Platform:

Replies:

6518 Aug 14,2003 03:45 PM Aug 15,2003 02:55 PM Windows Forms 6
loading
Tags: GridControl
ERobishaw
Asked On August 14, 2003 03:45 PM

I'm trying to get a list of Cells, or a single cell, that has changed in the CellsChanged method. HOwever, when I change the contents of a cell (via keyboard input), the method runs, but SavedCellsInfo is empty. E.Range does contain the changed cell's location. Any ideas? Eric

Administrator [Syncfusion]
Replied On August 14, 2003 04:12 PM

SavedCellsInfo is only populated if the grid's undo support is turned on. It is used by the grid in order to be able to undo these changes if necessary. You can get the list of changed cells from the range object. If you want the old values, you can set: Me.GridDataBoundGrid1.Model.CommandStack.Enabled = True then SaveCellsInfo should be non-empty.

ERobishaw
Replied On August 14, 2003 10:07 PM

I'm trying to avoid the CommandStack, b/c it saves way more than I need... in fact, that's the whole reason I was using SavedCellsInfo...I created my own simple CommandStack that only saves Text changes to cells. So...I was thinking I could use CellsChanging, but I can't figure out how to get the old values during that method, although they must be there, because if I set e.Cancel=true, then they are reverted. If the value is there internally, is there a public property that will return the old value as well? If not, I'll look for another way to go about this. Maybe there's a way to keep the CommandStack from saving virtually ALL changes... but I haven't figured it out yet. Thanks Eric > SavedCellsInfo is only populated if the grid's undo support is turned on. It is used by the grid in order to be able to undo these changes if necessary. You can get the list of changed cells from the range object. > > If you want the old values, you can set: > > Me.GridDataBoundGrid1.Model.CommandStack.Enabled = True > > then SaveCellsInfo should be non-empty.

Administrator [Syncfusion]
Replied On August 15, 2003 12:26 AM

In CellsChanging, you can get the old values directly from the grid through indexes, looping through the range object. In CellsChanged, the values in the grid have already been modified.

ERobishaw
Replied On August 15, 2003 08:42 AM

Doesn't hold true for me. I thought that same thing...but when I check the indexer value or text properties, it returns the new value/text. Example below: private void gridControl1_CellsChanging(object sender, Syncfusion.Windows.Forms.Grid.GridCellsChangingEventArgs e) { int RowIndex, ColIndex; string oldText=""; foreach (GridStyleInfo Style in e.CellsInfo) { RowIndex = Style.CellIdentity.RowIndex; ColIndex = Style.CellIdentity.ColIndex; oldText = gridControl1[RowIndex, ColIndex].Text); //always contains new value, not old } } > In CellsChanging, you can get the old values directly from the grid through indexes, looping through the range object. In CellsChanged, the values in the grid have already been modified.

Administrator [Syncfusion]
Replied On August 15, 2003 09:33 AM

You are right, I was wrong. There is a technical reason this works the way it does. The grid maintains a volatile cache of recently used style object for optimization purposes. So, in this situation a new style object for this new value has been created and is in this volatile cache. So, when you use grid[row,col] to reference a style, the grid retrieves this cached value instead of accessing the GridData object to retrieved the stored value. So, at this point, the new value appears to be stored in teh grid, but it really is only cached in teh volatile data store. The code below will retrieve the old value directly from the grid's GridData object as it is still there. I suspect your code would work if you called gridControl1.ResetVolatileData so the cache values are flushed, an dthe grid has to go to its GridData object to retrieve the data. But I am not sure if there are any side effects of calling ResetVolatileData at this point. Getting the data directly from the GridData object may be safer.
private void gridControl1_CellsChanging(object sender, GridCellsChangingEventArgs e)
{
	int row, col;
	GridData data = this.gridControl1.Data;
	bool b = e.Range.GetFirstCell(out row, out col);
	while(b)
	{
		string oldValue = "";
		if(data[row, col] != null)
		{
			GridStyleInfo style = new GridStyleInfo(data[row, col]);
			oldValue = style.Text;
			Console.WriteLine("({0},{1})=[{2}]   ", row, col, oldValue);
		}
		b = e.Range.GetNextCell(ref row, ref col);
	}
}

ERobishaw
Replied On August 15, 2003 02:55 PM

Thank-you very much. I can't get over the level of support you guys provide...phenomenal. Thanks Eric

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.

;