WinForms DataGrid控件的可编辑列标题?

时间:2010-08-06 10:54:46

标签: winforms datagridview columnheader

我想显示一个DataGrid控件,其中列标题可由用户编辑。这可能吗?

1 个答案:

答案 0 :(得分:0)

即使默认的DataGrid没有提供功能,我使用的解决方法是捕获列标题的click事件,然后使用InputBox()方法捕获新的列标题。

InputBox预先填充了默认列标题,然后验证输入字符串,我会更新标题。

请注意,我建议采用一种解决方法来实现功能。

InputBox() 位于Microsoft.VisualBasic.dll中,可以按如下方式访问:

Microsoft.VisualBasic.Interaction.InputBox()

带有以下签名

InputBox(prompt[, title] [, default] [, xpos] [, ypos] [, helpfile, context])

希望它有所帮助!