ListView row numbers?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to provide a list to the user. This list is the 1st 25 lines of
a given file. I want to provide the line number to the user, before each
line.

I see when I add Columns to a ListView, the way I want it to look. The
numbers appear fixed, and only show up for given lines.

What control are they using to accomplish this, and how is it configured?

I have been trying to get TextBox, ListBox, ListView, and DataGrid to do
this, but to no avail as of yet.

Any pointers would be greatly appreciated. I have not found anything
related to this on MSDN yet.

Andrew S. Giles
 
How are you adding your data to the ListView?

Using a custom class called Foo that has two string properties, A and B, and
building an array of Foos called fooArr and making sure that the View
property of the ListView is set to Details and that the desired number of
columns has been specified... you can do the following to add items to the
ListView and have each line be prefixed with a line #.

int x = 0;
foreach(Foo f in fooArr)
{
x++;
listView1.Items.Add( new ListViewItem( new
string[]{x.ToString(), f.A + " " + f.B, }) );
}

Is this more or less what you are trying to do?

Brendan
 
Back
Top