简体   繁体   English

在DataGridView中看不到DatePicker列的标题文本

[英]Can not see the header text of DatePicker Column in a DataGridView

I have three DateTime Picker columns in my DataGridView which I was able to achieve from this.. 我的DataGridView中有三个DateTime Picker列,我可以从中实现。

How to: Host Controls in Windows Forms DataGridView Cells 如何:在Windows Forms DataGridView单元中宿主控件

When I add only one Column of this type like this.. 当我只添加一个这种类型的列时..

Dim col As New CalendarColumn()
        col.HeaderText = "Date"
        col.Name = "Date"
        Me.DataGridView1.Columns.Add(col)

It works fine. 工作正常。 But when I add multiple columns like.. 但是当我添加多个列时..

 Dim col1 As New CalendarColumn()
    col.HeaderText = "Pledge Expiry Date"
    col.Name = "PledgeExpiryDate"
    Me.DataGridView1.Columns.Add(col1)

    Dim col2 As New CalendarColumn()
    col.HeaderText = "Security Maturity Date"
    col.Name = "SecurityMaturityDate"
    Me.DataGridView1.Columns.Add(col2)

I am able to see the Header text of only the Security Maturity Date rest of the two columns do not display their header text. 我只能看到“ Security Maturity Date的标题文本,其余两列均未显示其标题文本。

You missed out Something 你错过了什么

While adding second and third column you used same object name to assign Header Text and Name 在添加第二列和第三列时,您使用了相同的对象名称来分配标题文本和名称

col.HeaderText = "Pledge Expiry Date"
col.Name = "PledgeExpiryDate"

col.HeaderText = "Security Maturity Date"
col.Name = "SecurityMaturityDate"

Make Correction as 进行更正为

col1.HeaderText = "Pledge Expiry Date"
col1.Name = "PledgeExpiryDate"

col2.HeaderText = "Security Maturity Date"
col2.Name = "SecurityMaturityDate"

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

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