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.

Catching clicks of button in grouped grid when grouped

Thread ID:

Created:

Updated:

Platform:

Replies:

31270 Jul 4,2005 08:38 PM Jul 5,2005 03:08 AM Windows Forms 1
loading
Tags: GridControl
Damien Sawyer
Asked On July 4, 2005 08:38 PM

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 2.0.5.0 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

Administrator [Syncfusion]
Replied On July 5, 2005 03:08 AM

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

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.

;