473,385 Members | 1,720 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,385 software developers and data experts.

How to retrieve listview subitem data in C#.net 2008?

126 100+
Hello Friends,

I am using C#NET2008, Window Application with LISTVIEW.
I encounter an interesting problem while trying to retrieve 2 ListView SubItem column data of ORDERDATE and INVOICE for filling the TEXTBOX Control.

This is the ListView data display
CustID OrderDate Invoice
54321 25/12/2010 45363
56441 16/12/2010 45362

-----------------------------------------
After retrieving the SubItem Data into the TextBox instead of of just the OrderDate and Invoice data. This is what appeared on the TextBox:

ListView1SubItem: {25/12/2010}
ListView1SubItem: {45363}

Here are the coding that caused the above result.
Expand|Select|Wrap|Line Numbers
  1. private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  2.   {           
  3.   txtOrderDate.Text = Convert.ToString(this.listView1.SelectedItems[0].SubItems[1]);
  4.  txtInvoice.Text = Convert.ToString(this.listView1.SelectedItems[0].SubItems[2]);        
  5.   }
Feb 25 '11 #1
2 6471
What it's doing now is showing you the string representation of the referenced ListView SubItem object. What I believe you want is the "Text" property value associated with the SubItem, like below:

Expand|Select|Wrap|Line Numbers
  1. txtOrderDate.Text = listView1.SelectedItems[0].SubItems[1].Text;
  2. txtInvoice.Text = listView1.SelectedItems[0].SubItems[2].Text; 
Feb 27 '11 #2
lenniekuah
126 100+
Hello friends, finally I got the coding working by using this

Expand|Select|Wrap|Line Numbers
  1. strOrderID =  this.listView1.SelectedItems[0].Text ;
  2.  
  3. strOrderDate =  this.listView1.SelectedItems[0].SubItems[1].Text;
  4.  
  5. strProdID = this.listView1.SelectedItems[0].SubItems[2].Text;
Feb 27 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Stefan De Schepper | last post by:
Hi all, I made an overview of all my contacts. This overview is shown in a ListView. I programmatically add as many columns as there are in my contacts database table. All the contacts and their...
1
by: andrewcw | last post by:
The clcik event on the ListView control seems to trigger off the item level ( the first column ). I would like to be able to trap the click event on a particular subitem ( a specific column's row...
0
by: JuLiE Dxer | last post by:
Any advice/help on how to programmatically retrieve the meta-data from *.dvr-ms files ??? Thanks, MsJ
6
by: Jano | last post by:
Hello. I have one question I make Listview with 4 columns. And I want add text to to column 2,3,4. With listview1->Items->add ("Text") I can add text only to first column. In Visual basic.NEt I...
1
by: Jon | last post by:
Hi, How to add image to listview subitem? I can add image to the first column using ListViewItem("", 0) with a Imagelist. but cannot find a way to add to the subitem?? please help, many...
1
by: Lars Netzel | last post by:
Is it possible to have 5 Subitems in a listview and only take over the draw item for the last of them or do I have to draw the whole item? I just realized I need a little image before the text in...
2
by: jennifer1970 | last post by:
Hi. I am using VB 2005 Beta 2. I have never used a listview before. I am used to VB6. So please bear with me - I am trying to learn. I have a listview and want to be able to get the items ...
1
by: wilde | last post by:
hello, im new here in thescript.com im browsing the net looking for some forum which i could get some answers or idea for my question. i hope i can find one here......guys i want you to know...
1
by: James | last post by:
Hi All, I have an ownerdraw ListView control. I'm trying to use an ownerdrawn ListView control to draw and display images in the second column of a listview which is set to detail view. I...
0
by: girishpatil | last post by:
how to modify listview subitems data manually.listview is filled with data from datab
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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.