Computing.Net > Forums > Programming > Retrieving items from ListBox (C#)

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Retrieving items from ListBox (C#)

Reply to Message Icon

Name: El-Trucha
Date: May 2, 2005 at 13:25:29 Pacific
OS: Windows XP SP2
CPU/Ram: 2.8 GHz/448 MB
Comment:

Hello every1!! :D
OK, I need help here...I have a ListBox with View.Details and 4 columns, and I need to retrieve all of the items in it and then save them to an INI file...
I tried ListView.GetItemAt() but then I realized that the X and Y coordinates were the SCREEN coordinates, and not the rows/columns in the ListBox...
How can I get these items??
Can anybody please help me??
Thanx!! ;)

El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx



Sponsored Link
Ads by Google

Response Number 1
Name: Chi Happens
Date: May 3, 2005 at 07:27:51 Pacific
Reply:

Ah you are actually using a list view not a list box:

System.IO.TextWriter wr = System.IO.File.CreateText("text.ini");

for(int t=0;t<ListView1.Items.Count;t++)
{
string aline = ListView1.Items[t].Text + ","; // comma delimited
for(int s=1;s<ListView1.Items[t].SubItems.Count;s++)
{
aline += ListView1.Items[t].SubItems[s].Text + ",";// comma deliminted
}
aline = aline.SubString(0,aline.Length-1); // remove trailing comma
wr.WriteLine(aline);
}

wr.Flush();
wr.Close();

Hope this helps some,
Chi


They mostly come at night...mostly


0

Response Number 2
Name: El-Trucha
Date: May 3, 2005 at 16:12:22 Pacific
Reply:

YES!!
It worked!! thanx!! ;) (and yes, it was ListView... :P )
But now, if it doesn't bother, can you tell me 3 more things about ListViews??

1. What's the ListView property that arranges the items when you click on a column?? or do I have to do it manually??

2. Is there an automated way so that when the user deletes an item from a ListView, the next one replaces the one deleted, etc...

3. How do I do it so like when a user clicks 2 times on a ListView item, it becomes writable?? it does it fine on the first item, but not on its sub items...

Much thanx!! ;)

El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Retrieving items from ListBox (C#)

VB Removing Items from list Box www.computing.net/answers/programming/vb-removing-items-from-list-box/9822.html

calling a C from another C www.computing.net/answers/programming/calling-a-c-from-another-c/7414.html

Insert item in array (C#) www.computing.net/answers/programming/insert-item-in-array-c/13076.html