M
markliam
How would I declare a fixed number of ColumHeader objects without
having to manually type "new ColumnHeader()" for each one? Is it even
possible? I'm thinking there has to be an easier way than this:
// CREATE LISTVIEW COLUMNS
ColumnHeader[] columns = { new ColumnHeader(), new
ColumnHeader() }; // this is what I'd like to shorten
columns[0].Text = "Test Column";
columns[0].Width = 100;
columns[1].Text = "Test Column #2";
columns[1].Width = 200;
listView1.Columns.AddRange(columns);
having to manually type "new ColumnHeader()" for each one? Is it even
possible? I'm thinking there has to be an easier way than this:
// CREATE LISTVIEW COLUMNS
ColumnHeader[] columns = { new ColumnHeader(), new
ColumnHeader() }; // this is what I'd like to shorten
columns[0].Text = "Test Column";
columns[0].Width = 100;
columns[1].Text = "Test Column #2";
columns[1].Width = 200;
listView1.Columns.AddRange(columns);