当我右键单击网格行时,它会显示分配给它的上下文菜单条几秒钟,然后用表单的上下文菜单替换它。如果单击在网格上,我如何确保网格的上下文菜单条保持可见。
代码:
private void Form1_Load(object sender, EventArgs e)
{
Matches();
DataTable dt = new DataTable();
dt.Columns.Add("Test", typeof(string));
dt.Rows.Add("A");
dt.Rows.Add("A");
dt.Rows.Add("A");
dt.Rows.Add("A");
dt.Rows.Add("A");
dt.Rows.Add("A");
ContextMenuStrip ctsForm = new ContextMenuStrip();
ctsForm.Items.Add("Form");
ctsForm.Opening+=ctsForm_Opening;
ctsGrid.Items.Add("Grid");
gridControl1.DataSource = dt;
gridView1.PopupMenuShowing+=gridView1_PopupMenuShowing;
this.ContextMenuStrip = ctsForm;
}
private void ctsForm_Opening(object sender, CancelEventArgs e)
{
}
private void gridView1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
{
GridView view = (GridView)sender;
GridHitInfo hitInfo = view.CalcHitInfo(e.Point);
if (hitInfo.InRow)
{
view.FocusedRowHandle = hitInfo.RowHandle;
ctsGrid.Show(view.GridControl, e.Point);
}
}