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

grid grouping control basic

Thread ID:

Created:

Updated:

Platform:

Replies:

54061 Dec 28,2006 03:35 PM UTC Dec 29,2006 05:33 AM UTC Windows Forms 1
loading
Tags: GridControl
lee p.
Asked On December 28, 2006 03:35 PM UTC

Hi, I am new to ggc and have a few questions. I have dataset/datatable as a data source to the ggc.
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?

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

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.


Thanks

Administrator [Syncfusion]
Replied On 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

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

;