Hi, is it possible to code column header in listview during run time?

can you please give me some idea on this.Thank you in advance.

5 Years
Discussion Span
Last Post by jemz

If you go into design view, right click on the listview and select "Edit Columns" you will see the names of all the columns (you can change these names). You can use these names to modify the header text at runtime as in

ColumnHeader1.Text = "new header text"

If you need to add column headers at runtime, I've found the best way to find out how this is done is to create the headers at design time, then look at the contents of Form1.Designer.vb in your project folder (replace Form1 with your actual form name if different). This file contains the code to create the controls. You can use the same code at runtime.

Edited by Reverend Jim


@Reverend Jim, Thank you for the reply,but any alternative way to code on it...I tried your first solution the edit columns, but i have no idea on how to make column header to code...


Does this help

Dim newheader As New System.Windows.Forms.ColumnHeader
newheader.Text = "my text"
newheader.Width = 60
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.