BCGSoft.Controls.Grid Namespace > Cell Class : GetEditData Method |
The GridControl calls this method when the user has finished to edit a cell and the modified data (or new data if the cell was empty) is about to be written back to GridDataItem.DataItem.
If your custom GridDataItem represents a complicated structure and only few fields of this structure has been updated, you have to just update these fields in the original ItemData object and set GridDataItem.Updated property to true. This will preserve the old (original) reference to data, but still cause the Grid to raise DataItemUpdated event.
For example, you have some complicated item data:
public class MyCustomItemData
{
public Text;
public Param1;
public Param2;
}
public override object GetEditData ()
{
if (DataItem == null || DataItem.ItemData == null)
{return null;
}
// get the original data stored in the cell before editMyCustomItemData item = (MyCustomItemData) DataItem.ItemData;
// modify it with text taken from edit control
item.Text = m_editControl->Text;
// set update flag to make the caller understand that the item has been updated
item.Updated = true;
return item;
}
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2