[英]Change the column header caption in a WinForm DataGridView
How to change the row name with option button? 如何使用选项按钮更改行名称?
If option button export selected: 如果选择了选项按钮导出:
Private sub optexport_click()
txtimport = "I"
fgcargo.textmatrix(0,2) = "bl number"
fgcargo.textmatrix(0,4) = "date"
end sub
If option button import selected: 如果选择了选项按钮导入:
Private sub optimport_click()
txtimport = "E"
fgcargo.textmatrix(0,2) = "so number"
fgcargo.textmatrix(0,4) = "date"
end sub
The GridView will take it's column names from the data source. GridView将从数据源中获取它的列名。 This means that if you have a column named "bl_number" in the database, the column in the GridView will name the column "bl_number".
这意味着如果数据库中有一个名为“bl_number”的列,则GridView中的列将命名列“bl_number”。
You could try something like the following: 您可以尝试以下内容:
fcargo.HeaderRow.Cells(2).Text = "bl number"
fcargo.HeaderRow.Cells(4).Text = "date"
Where Cells(ByVal index As Integer)
is the index of the column in the GridView (0 based). 其中
Cells(ByVal index As Integer)
是GridView中列的索引(基于0)。
Hope this helps. 希望这可以帮助。
NOTE: This will not work with a Windows Forms DataGridView control. 注意:这不适用于Windows窗体DataGridView控件。
For a Windows Forms DataGridView, go into it's columns collection. 对于Windows窗体DataGridView,请进入它的列集合。 You can change the header text for each column there.
您可以更改每列的标题文本。 In code, you could try the following:
在代码中,您可以尝试以下操作:
fcargo.Columns(2).Name = "bl number"
fcargo.Columns(4).Name = "date"
Good luck! 祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.