繁体   English   中英

更改WinForm DataGridView中的列标题标题

[英]Change the column header caption in a WinForm DataGridView

如何使用选项按钮更改行名称?

如果选择了选项按钮导出:

Private sub optexport_click()
    txtimport = "I"
    fgcargo.textmatrix(0,2) = "bl number"
    fgcargo.textmatrix(0,4) = "date"
 end sub

如果选择了选项按钮导入:

Private sub optimport_click()
    txtimport = "E"
    fgcargo.textmatrix(0,2) = "so number"
    fgcargo.textmatrix(0,4) = "date"
 end sub

GridView将从数据源中获取它的列名。 这意味着如果数据库中有一个名为“bl_number”的列,则GridView中的列将命名列“bl_number”。

您可以尝试以下内容:

fcargo.HeaderRow.Cells(2).Text = "bl number"
fcargo.HeaderRow.Cells(4).Text = "date"

其中Cells(ByVal index As Integer)是GridView中列的索引(基于0)。

希望这可以帮助。

注意:这不适用于Windows窗体DataGridView控件。
对于Windows窗体DataGridView,请进入它的列集合。 您可以更改每列的标题文本。 在代码中,您可以尝试以下操作:

fcargo.Columns(2).Name = "bl number"
fcargo.Columns(4).Name = "date"

祝好运!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM