Hi,
I loaded the data from database to listbox in my form. (every time it retrieves different number from the database)
now my listbox contains items as follows: (1st time:)
1021
1022
1023
later my listbox contains like this:
1021
1023
I have a text file like this: (I have almost 1000 rows here i am giving you only 3 rows)
1021 darma
1022 teja
1023 vulpes
Now i want to change my listbox numbers as follows:
1st time listbox should show like this:
darma
teja
vulpes
2nd time listbox should show like this:
darma
vulpes
Give me ideas to do.
Thanks allot
Darma
Loading

VulpesRank #55 · 29.2K reputationPosted May 16, 2012, 6:40 AM EDT
Here's a modification to the previous code to deal with that:
VulpesRank #55 · 29.2K reputationPosted May 16, 2012, 4:49 AM EDT
listBox1.DataSource = names;
This assumes there are no blank lines in the file.
darma tejaRank #3,199 · 449 reputationPosted May 16, 2012, 5:40 AM EDT
Thanks allot for your reply.
Your code is to get all the names in listbox.
Actually i should not get all the names in my listbox.
These list box items are retrieved from other list box selected index changed event.
Now my list box get different numbers in different times based on other list box selected index changed event.
Based on the listbox numbers, i will change in names automatically.
Darma
VulpesRank #55 · 29.2K reputationPosted May 16, 2012, 5:59 AM EDT
May be like this:
darma tejaRank #3,199 · 449 reputationPosted May 16, 2012, 6:32 AM EDT
Thanks allot once again.
I am getting exception at the line: dict.Add(items[0], items[1]);
The exception is like this: "An item with the same key has already been added"
Darma
darma tejaRank #3,199 · 449 reputationPosted May 16, 2012, 7:19 AM EDT
You are genius man.
Darma