This c# code creates columns with columnheader for the items and subitems in a listview. There are different ways to create columns.
ColumnHeader column1 = new ColumnHeader(); column1.Width = 100; column1.Text = "Column 1"; column1.TextAlign = HorizontalAlignment.Right; listView1.Columns.Add(column1); listView1.Columns.Add("Column 2", 120, HorizontalAlignment.Center); // Width of -1 indicates to adjust the width of the longest item in the column. listView1.Columns.Add("Column 3", -1, HorizontalAlignment.Left); // Width of -2 indicates to autosize to the width of the column heading. listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Left);
Antworten