Search code examples
vb.netdatagridviewellipsisdynamic-columns

Show ellipsis in DataGrid Column Header vb.net


I am using DataGridView in my Windows Form.

I am dynamically adding columns and populating row values, the issue is, I have set my columns width property to a fixed size, when my column's header exceeds the max width it show the remaining on next line, I have set the Header's height to a fixed size.

I want to show the text ... when the columns width ends.

I am attaching the image of my requirement, I have added Cell_Painting as well but its not working, that is basically for data, aslo I have

DataGridView1.DefaultCellStyle.WrapMode = DataGridView1.DefaultCellStyle.WrapMode

enter image description here


Solution

  • I have used below line in Form_Load event and got my desired result

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DataGridView1.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False
    End Sub
    

    enter image description here