Context menu will not show unless right-click occured on a selected record. Please help.

I want to accomplish the following...

1. I have a grid in which I want to be able to multi-select rows.
2. I want to maintain my selection when I do a right-click on the ggc so that I can take some actions on the the selected records.
3. I also want to maintain my selection unless a certain column index are clicked. For example, if I have 5 columns, only the last two columns should toggle my selection.
4. I want to be able to right-clicked on ANY row and bring up the context menu.


I have the following settings..
this.gridGroupingControl2.TableControl.Selections.Clear();
this.gridGroupingControl2.TableOptions.AllowSelection = GridSelectionFlags.None;
this.gridGroupingControl2.TableOptions.ListBoxSelectionMode = SelectionMode.MultiSimple;
this.gridGroupingControl2.TableModel.Options.SelectCellsMouseButtonsMask = MouseButtons.Left;


I am handling the following event for my context menu....

private void gridGroupingControl2_TableControlCellClick(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs e)
{
GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex];
if (style.TableCellIdentity.ColIndex == 1 && style.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell)
e.Inner.Cancel = true;

if (e.Inner.MouseEventArgs.Button == MouseButtons.Right)
{
int row, col;
Point pt = new Point(e.Inner.MouseEventArgs.X, e.Inner.MouseEventArgs.Y);
if (e.TableControl.PointToRowCol(pt, out row, out col))
e.TableControl.CurrentCell.AdjustRowColIfCoveredCell(ref row, ref col);

tableCellStyle = e.TableControl.GetTableViewStyleInfo(row, col);
contextElement = tableCellStyle.TableCellIdentity.DisplayElement;

this.contextMenu.Items.Clear();
if (contextElement is GridRecordRow)
{
this.contextMenu.Items.Add("Combine", null, new EventHandler(on_item_clicked));
this.contextMenu1.Show(this, this.PointToClient(Control.MousePosition));
}

}



... however, the context menu will not come up until I right-click in the CURRENT cell of the CURRENTLY selected row.

When I right click on a row that is not selected, nothing happens.

I want to be able to right click anywhere on the grid and bring up the context menu.

Please help!


1 Reply

JB James Blibo February 5, 2007 06:47 PM UTC

Never mind this... I've decided to use a checkbox celltype instead of relying on the ggc Selection.

Loader.
Up arrow icon