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

CheckBox Click Followed by Context Menu Popup

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

7 Replies

BI Billie October 28, 2005 10:14 PM UTC

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


AD Administrator Syncfusion Team October 28, 2005 10:50 PM UTC

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]);
			}
		}
	}
}


BI Billie October 29, 2005 12:11 AM UTC

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


AD Administrator Syncfusion Team October 29, 2005 09:57 AM UTC

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


BI Billie October 31, 2005 09:10 PM UTC

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


AD Administrator Syncfusion Team November 1, 2005 08:37 AM UTC

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]);
	}
}


BI Billie November 1, 2005 11:24 PM UTC

Clay, It worked perfectly. Thank you much. Billie

Loader.
Live Chat Icon For mobile
Up arrow icon