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. Image for the cookie policy date
close icon

Catching clicks of button in grouped grid when grouped

Hi, I''ve got a button in a grouped grid control. I am using the following code to catch clicks of it (based on the name of the column). This works fine until the grid is ''grouped''. I am guessing that the plus buttons that appear on the left take up one of the column positions and that I need to offset my ColIndex by the number of groupings. Could someone please explain how I find out the number of groupings? or... if there are other flaws in this plan that I''ve not come accross yet, the ''correct'' way to do this? We are using version of the grid. Thanks very much in advance, Damien Sawyer private void grItems_TableControlPushButtonClick(object sender, GridTableControlCellPushButtonClickEventArgs e) { int i = this.grItems.TableDescriptor.Columns.IndexOf(_TimePhasedButtonName); if (e.Inner.ColIndex == i+1) { MessageBox.Show("Button pressed on Row " + e.Inner.RowIndex.ToString()); } } Can s

1 Reply

AD Administrator Syncfusion Team July 5, 2005 07:08 AM UTC

Normally, you only make minimal use of row/column indexes in a GridGroupingControl. The reason is that as you have multiple groupings and/or nested tables and/or extra sections in your grid and/or filters and/or summaries, the rows/columns become less intuitive to use. You can use code like this to get the TableCellStyleInfo object for the cell. GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex]; Once you have this object, you know about everything there is to know about a cell, but you do have to conditionally access information, as not all properties are populated for all types of cells. If you want to pick out a column by name, you can use:
private void gridGroupingControl1_TableControlPushButtonClick(object sender, 
	                                 GridTableControlCellPushButtonClickEventArgs e)
	GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex];
	if(style.TableCellIdentity.Column != null 
		&& style.TableCellIdentity.Column.MappingName == (_TimePhasedButtonName)
		MessageBox.Show("Button pressed on Row " + e.Inner.RowIndex.ToString());
If you want the group level, you can use: style.TableCellIdentity.DisplayElement.GroupLevel

Live Chat Icon For mobile
Up arrow icon