简体   繁体   中英

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..

How to: Host Controls in Windows Forms DataGridView Cells

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.

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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