Listview question

  • Thread starter Thread starter Kay
  • Start date Start date
K

Kay

Hi all,

I know that I can get the value of a particualar column in a list view by
something like this:
lvwRoster.SelectedItems(0).SubItems(2).Text

However, is it possible to get the value by column name? In vb.net you can
assign a column name for each column, but I don't know where I can use
it.... any idea?

Thx~~~

Kay
 
Kay,

A listview is not a datatable (dataview).
A listview has headers but AFAIK no column names,

Cor
 
It has Cor...in a listview's property, it has a "columns" collection, in
each column you can assign a name there, it also where you can assign the
column Text.... am I correct?

Kay
 
Kay,

But AFAIK does by instance a datatable column describe a datarow item.
(Therefore you cannot simple move a datarow to another datatable).

A listview column describes only a header column not a
listviewitemcollection item.

Cor
 
Hi all,

I know that I can get the value of a particualar column in a list view by
something like this:
lvwRoster.SelectedItems(0).SubItems(2).Text

However, is it possible to get the value by column name? In vb.net you can
assign a column name for each column, but I don't know where I can use
it.... any idea?

Thx~~~

Kay

The DataGridView control, unbound, can be configured to look indentical to a ListView, Detail View,
and will give you the functionality you are looking for.

Gene
 
Kay said:
Hi all,

I know that I can get the value of a particualar column in a list
view by something like this:
lvwRoster.SelectedItems(0).SubItems(2).Text

However, is it possible to get the value by column name? In vb.net
you can assign a column name for each column, but I don't know where
I can use it.... any idea?

Thx~~~

Kay

Kay,

If you set the Name property on the ListViewItem and the ListViewSubItems as you add them into the ListView you can then access the
columns by name. For example, if you set the ListViewItem.Name to "FirstName" then you can access the column as:

lvwRoster.SelectedItems(0).SubItems("FirstName").Text

I hope this helps.
 
Back
Top