Problem with GDBG and PopupMenu
I have a GridDataBoundGrid and I have set a syncfusion PopupMenu to it as follow:
this._PopupMenusManager.SetXPContextMenu(this.gridTimer, this._LogicInputPopupMenu);
But I actually want the popup menu shows up only when I right click on last column of my grid. So I added BeforePopup event to check the column index and cancel the popup menu for any other columns except the last column. I also set
the following:
this.gridTimer.Model.Options.SelectCellsMouseButtonsMask = MouseButtons.Left | MouseButtons.Right;
Here are the two events:
private void gridTimer_MouseDown(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Right)
{
Point clickPoint = this.gridTimer.PointToClient(Cursor.Position);
this._LogicInputPopupMenu.Show (this.gridTimer, clickPoint);
}
}
private void LogicInputPopupMenu_BeforePopup(object sender, Syncfusion.Windows.Forms.CancelMouseEventArgs e)
{
if (this.gridTimer.CurrentCell.ColIndex != 11)
{
e.Cancel = true; // cancel the Popup menu anywhere beside the StopEvent column
}
}
The problem is when I right click on last column it shows up the PopupMenu but when I right click on another column it still shows up the menu but after that it works fine. It seems the second right click doesn''t move the cursor to other column but finally the third right click moves the focus to the third column. Any idea why it works like this.
SIGN IN To post a reply.
4 Replies
MJ
Mano J
Syncfusion Team
December 16, 2005 10:27 AM UTC
Hi,
Please try commenting out the code in the mousedown event. Since you have associated the popupmenu to GDBG and allowed it to show only on the last column using before_popup, there is no need to make the popupmenu to show when mouse down occurs in the GDBG.
I have attached a sample that demonstrates this completely. Please refer to it and let me know if this meets your requirements.
Thanks for using Syncfusion products.
Regards,
Mano
GDBG_Popupmenu.zip
NJ
Najmeh Joze-khajavi
December 16, 2005 02:11 PM UTC
Thanks for relay. I need to have that code in MouseDown event or something else equivalent to that. I see your sample is working but there is a difference with your sample and my application. My last column is combobox cell type (combobox in GDBG cell). If I don''t have the code in MouseDown event when I right click I see very quickly the Popup menu but it doesn''t stay and it opens the combobox list. In your sample you have textbox cell type and right click brings the Popupmenu. Any other idea?
ST
stanleyj
Syncfusion Team
December 16, 2005 03:33 PM UTC
Hi Najmeh,
Try moving the current cell focus in the MouseDown handler to the location of the mouse cursor.
int row,col;
private void gridTimer_MouseDown(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Right)
{
Point clickPoint = this.gridTimer.PointToClient(Cursor.Position);
this.gridTimer.PointToRowCol(clickPoint, out row, out col);
this.gridTimer.CurrentCell.MoveTo(row, col);
this._LogicInputPopupMenu.Show (this.gridTimer, clickPoint);
}
}
Let me know if this helps.
Best regards,
Stanley
NJ
Najmeh Joze-khajavi
December 16, 2005 04:22 PM UTC
Thanks it works. The key line was
this.gridTimer.CurrentCell.MoveTo(rowIndex, colIndex);
I have already used CurrentCell.Activate as follow:
this.gridTimer.CurrentCell.Activate(rowIndex, colIndex);
But that didn''t do the job, "MoveTo" did the job correctly. Thanks.
SIGN IN To post a reply.
- 4 Replies
- 3 Participants
-
NJ Najmeh Joze-khajavi
- Dec 15, 2005 09:00 PM UTC
- Dec 16, 2005 04:22 PM UTC