AD
Administrator
Syncfusion Team
December 29, 2006 05:33 AM UTC
Hi Lee,
>>>1. When a user click on a row, how can I tell which row/column it is and how to retrieve the underlying record in the datatable?
You can get the current record and current column details from currentcell using the following code.
private void gridGroupingControl1_TableControlCellClick(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
//Get the TableCellStyleInfo from GridStyleInfo object
GridTableCellStyleInfo style = cc.Renderer.CurrentStyle as GridTableCellStyleInfo;
if( style != null && style.TableCellIdentity.Column != null)
{
Element eDisplayElement = style.TableCellIdentity.DisplayElement;
if( eDisplayElement.Kind == DisplayElementKind.Record && eDisplayElement.ParentTable != null )
{
DataRowView datarow = eDisplayElement.ParentTable.CurrentRecord.GetData() as DataRowView;
Console.WriteLine("Current Record:" + eDisplayElement.ParentTable.CurrentRecord);
Console.WriteLine("Current ColumnName: " + style.TableCellIdentity.Column.Name);
}
}
}
>>> 2. One of the data is an custom object that I would normally use tag property of treeview or datagrid to store it. How would I store that type of information in the ggc. (In other word, each row of the ggc control is referring to a custom object.)
Try setting the Style.CellValueType property of the cell in a grid to store the type information of the custom object.
//set the cell type information using TableControlPrepareViewStyleInfo event of the grid.
e.Inner.Style.CellValueType = typeof(YourType);
>>> 3. If the underlying data in the table get changed, how do I let the ggc knows - which properties or event do I need to subscribe/set? Similary, if the user change data on the grid, how to I save it back to the table / data source.
The following events are used to detect the underlying datasource changes in a grid.
1) SourceListRecordChanged event - occured when a record in the underlying datasource are added/delted/changed.
2) SourceListListChanged event - gives the more details about the SourceListRecordChanged event.
Try calling the Table.EndEdit() method to update the changes in a grid to underlying datasource.
this.grid.Table.TableDirty = true;
this.grid.Tabel.EndEdit();
Best Regards,
Haneef