473,386 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Listview question

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
Aug 22 '06 #1
5 2195
Kay,

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

Cor

"Kay" <kk@kk.com.kkschreef in bericht
news:eH**************@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

Aug 22 '06 #2
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
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eX**************@TK2MSFTNGP03.phx.gbl...
Kay,

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

Cor

"Kay" <kk@kk.com.kkschreef in bericht
news:eH**************@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


Aug 22 '06 #3
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

"Kay" <kk@kk.com.kkschreef in bericht
news:ej****************@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]" <no************@planet.nlwrote in message
news:eX**************@TK2MSFTNGP03.phx.gbl...
>Kay,

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

Cor

"Kay" <kk@kk.com.kkschreef in bericht
news:eH**************@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



Aug 22 '06 #4
On Tue, 22 Aug 2006 13:34:58 +1000, "Kay" <kk@kk.com.kkwrote:
>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
Aug 22 '06 #5
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").T ext

I hope this helps.

--
Al Reid
Aug 22 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: andrewcw | last post by:
I have a simple winform with the following code. But although I can read back the info, the display fails to provide the text or the cell background color changes. private void ListViewBroke()...
1
by: J_Max | last post by:
Hello, This might be a really easy question, but... I am developing a simple Smart Device application that uses a listview. I have a function that adds a item to the listview - code is below. I...
7
by: Dave Y | last post by:
I am a newbie to C# and am having trouble trying to override a ListView property method. I have created a new class derived from the Forms.Listview and I cannot figure out the syntax to override...
3
by: MikeY | last post by:
Hopefully someone can help me on this. I am using C#, making Windows forms. I have created a listView with checkbox's. I have enabled the checkboxes under the properties, and all the data,...
1
by: Derck | last post by:
SORRY, for the crosspost, but I think I posted it in the wrong group! Hello all, I have a question.. I am tying to make a global listview class where other listviews in my application points...
12
by: J L | last post by:
When I fill a listview, I resize the columns to fit the data. I need to know if the data will fit vertically or if there will be a vertical scroll bar. I need to know this so I can allow for it on...
1
by: Chris | last post by:
Hi all, I posted the following in microsoft.public.dotnet.framework.windowsforms but it seems that group has little traffic. Hi all, I have a listview box which is populated from methods of...
12
by: garyusenet | last post by:
I have had no replies to my previous post so perhaps I didn't write it good enough. Please excuse new thread but i wanted to break from the last thread hopefully this thread will be better. ...
1
by: =?Utf-8?B?THluYkBtcy5jb20=?= | last post by:
I have a executable winforms application I would like to change. I use quite a number of listview controls in my main form. I dump about 15 columns of data into a couple of listviews. This data...
5
by: Mark Olbert | last post by:
How do I get the DataPager and ListView to play nice together when I use a custom datasource? In my webpage, I use linq to pull data from a SqlServer database and assign the resulting...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.