Home All Groups Group Topic Archive Search About
Author
22 Aug 2006 3:34 AM
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

Author
22 Aug 2006 5:03 AM
Cor Ligthert [MVP]
Kay,

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

Cor

Show quoteHide quote
"Kay" <k*@kk.com.kk> schreef in bericht
news:eH3wUuZxGHA.3788@TK2MSFTNGP02.phx.gbl...
> 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
>
Author
22 Aug 2006 6:02 AM
Kay
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


Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:eXPUXgaxGHA.4968@TK2MSFTNGP03.phx.gbl...
> Kay,
>
> A listview is not a datatable (dataview).
> A listview has headers but AFAIK no column names,
>
> Cor
>
> "Kay" <k*@kk.com.kk> schreef in bericht
> news:eH3wUuZxGHA.3788@TK2MSFTNGP02.phx.gbl...
>> 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
>>
>
>
Author
22 Aug 2006 6:20 AM
Cor Ligthert [MVP]
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

Show quoteHide quote
"Kay" <k*@kk.com.kk> schreef in bericht
news:ej0%230AbxGHA.5064@TK2MSFTNGP04.phx.gbl...
> 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
>
>
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
> news:eXPUXgaxGHA.4968@TK2MSFTNGP03.phx.gbl...
>> Kay,
>>
>> A listview is not a datatable (dataview).
>> A listview has headers but AFAIK no column names,
>>
>> Cor
>>
>> "Kay" <k*@kk.com.kk> schreef in bericht
>> news:eH3wUuZxGHA.3788@TK2MSFTNGP02.phx.gbl...
>>> 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
>>>
>>
>>
>
>
Author
22 Aug 2006 6:30 AM
gene kelley
Show quote Hide quote
On Tue, 22 Aug 2006 13:34:58 +1000, "Kay" <k*@kk.com.kk> wrote:

>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
Author
22 Aug 2006 11:34 AM
Al Reid
Kay wrote:
> 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.

--
Al Reid