C1FlexGrid 右击菜单ContextMenuStrip
1.有单元格右击,不显示菜单。 2.现在窗体加入控件ContextMenuStrip。
1 private void fgMain_MouseClick(object sender, MouseEventArgs e) 2 { 3 if (e.Button == MouseButtons.Right) 4 { 5 int row = this.fgMain.MouseRow; 6 int col = this.fgMain.MouseCol; 7 8 if (row < 1 || col < 1) 9 { 10 return; 11 } 12 13 this.fgMain.Focus(); 14 this.fgMain.Select(row, col); 15 16 if ((row == 1 && col == 1)) 17 { 18 return; 19 } 20 21 if (this.fgMain.Rows.Count > 30) 22 { 23 this.fgMain.ContextMenuStrip = this.menuFG; 24 this.fgMain.ContextMenuStrip.Show(Cursor.Position); 25 } 26 } 27 } 28 29 private void fgMain_BeforeMouseDown(object sender, BeforeMouseDownEventArgs e) 30 { 31 this.fgMain.ContextMenuStrip = null; 32 }