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.

CheckBox Click Followed by Context Menu Popup

Thread ID:

Created:

Updated:

Platform:

Replies:

36411 Oct 28,2005 04:31 PM Nov 1,2005 06:24 PM Windows Forms 7
loading
Tags: Grouping
Administrator [Syncfusion]
Asked On October 28, 2005 04:31 PM

Hi! I''m using v 3.2.1.0 GridGroupingControl. In the event handler for context menu popup, I needed to evaluate if the current row has changed. So I used the this.Grid.Table.GetInnerMostCurrentElement() to get a DataRowView and set the menu enable state Based on its DataRow''s RowState. It works just fine except if the previously changed cell is a checkbox. The current element seems to stay as the checkbox cell, instead of the right-mouse clicked cell. How do I make it consistent? Thanks, Billie

Billie
Replied On October 28, 2005 06:14 PM

Oops! Didn''t mean to be "Anonymous". I''m the originator. Billie >Hi! I''m using v 3.2.1.0 GridGroupingControl. In the event handler for context menu popup, I needed to evaluate if the current row has changed. So I used the this.Grid.Table.GetInnerMostCurrentElement() to get a DataRowView and set the menu enable state Based on its DataRow''s RowState. > >It works just fine except if the previously changed cell is a checkbox. The current element seems to stay as the checkbox cell, instead of the right-mouse clicked cell. How do I make it consistent? > >Thanks, >Billie

Administrator [Syncfusion]
Replied On October 28, 2005 06:50 PM

Here is a forum thread that discusses displaying a context menu and getting the cell under the click. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=20103 It uses the TableControlCellMouseUp event to show the menu. The e.Inner.RowIndex and e.Inner.ColIndex pick out the row and column. But if you are using our XPMenus so that you do not control the popup action, you can handle the BeforePopUp event to catch teh click DataRowView.
private void popupMenu1_BeforePopup(object sender, Syncfusion.Windows.Forms.CancelMouseEventArgs e)
{
	Point pt = this.gridGroupingControl1.TableControl.PointToClient(Control.MousePosition);
	int row, col;
	if(this.gridGroupingControl1.TableControl.PointToRowCol(pt, out row, out col))
	{
		GridTableCellStyleInfo style = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(row, col);
		GridRecord record = style.TableCellIdentity.DisplayElement.ParentRecord as GridRecord;
		if(record != null)
		{
			DataRowView drv = record.GetData() as DataRowView;
			if(drv != null)
			{
				Console.WriteLine("{0} {1} {2}", drv[0], drv[1], drv[2]);
			}
		}
	}
}

Billie
Replied On October 28, 2005 08:11 PM

Thank you, Clay. It works fine with a flat table or the top level of parent table when all rows are collapsed, but not a child table of a hierarchical grid. Billie

Administrator [Syncfusion]
Replied On October 29, 2005 05:57 AM

You have to get the proper TableControl when you have nested tables. Here is a little sample that uses the TableControlCellClick event. The proper table is passed in as an event arg in this event. http://www.syncfusion.com/Support/user/uploads/GDBG_XPContextMenu_f2edf3fc.zip

Billie
Replied On October 31, 2005 04:10 PM

Clay, Thank you for the sample, but the CellClick event happens after the context menu popup event. The complication here is that the GridGroupingControl is inside of a user control which has a context menu merged with that of the GGC. It needs to do some processing in the menu Popup event. Any other alternatives? Thank you in advance. Billie

Administrator [Syncfusion]
Replied On November 1, 2005 03:37 AM

Try code like:
Point pt = this.gridGroupingControl1.TableControl.PointToClient(Control.MousePosition);
Element el = this.gridGroupingControl1.TableControl.PointToNestedDisplayElement(pt);
if(el is GridRecordRow)
{
	GridRecord rec = el.ParentRecord as GridRecord;
	if(rec != null)
	{
		DataRowView drv = rec.GetData() as DataRowView;
		Console.WriteLine("{0} {1} {2}", drv[0], drv[1], drv[2]);
	}
}

Billie
Replied On November 1, 2005 06:24 PM

Clay, It worked perfectly. Thank you much. Billie

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.

;