FlexGrid如何设置右键菜单?是否有相关事例?
本帖最后由 Quanweiz 于 2022-11-14 13:36 编辑1.FlexGrid如何设置右键菜单?是否有相关事例?
2.通过下面方法导入的EXCEL文件数据如果增加行号?
OpenFileDialog dlg = new OpenFileDialog();
dlg.DefaultExt = "xls";
dlg.FileName = "*.xls";
if (dlg.ShowDialog() != DialogResult.OK)
return false;
_flex.DataSource = null;
string[] sheets = _flex.LoadExcelSheetNames(dlg.FileName);
FileFlags flags = FileFlags.LoadMergedRanges | FileFlags.IncludeFixedCells;
_flex.LoadExcel(dlg.FileName, str, flags);
加载后设置下面参数设置都无效,附件为导入EXCEL文件。
_flex.Cols.Fixed = 2;
_flex.Rows.DefaultSize = 50;//设置所有行的默认大小
也没有行号出现?
1。右键菜单和其他的winforms控件一样的,设置ContextMenu属性就行,我估计你想要问的主要是获取右键点击弹出ContextMenu时,所在的单元格行列信息
这个可以通过mouseclick事件来判断,通过hitTes方法获取
2.可以通过OwnerDrawCell事件设置,
c1FlexGrid3.DrawMode = DrawModeEnum.OwnerDraw;
c1FlexGrid3.OwnerDrawCell += C1FlexGrid3_OwnerDrawCell;
private void c1FlexGrid2_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)
{
if (e.Col == 0)
{
e.Text = e.Row.ToString();
}
//if (e.Col == c1FlexGrid2.Cols["EmployeeID"].Index && e.Row == c1FlexGrid2.Rows.Count - 1)
//{
// double d = Convert.ToDouble(e.Text);
// e.Text = String.Format("{0:#,##0.00}", d);
//}
} 都用了C1FlexGrid,右键菜单必须得用C1ContextMenu啊。
Private Sub C1FlexGrid_MouseUp(sender As Object, e As MouseEventArgs) Handles C1FlexGrid.MouseUp
If e.Button = MouseButtons.Right Then
C1ContextMenu.ShowContextMenu(C1FlexGrid, e.Location)
End If
End Sub 本帖最后由 Richard.Ma 于 2022-12-13 16:11 编辑
:hjyzw: C1ContextMenu比普通的ContextMenu当然更好用一些
页:
[1]