Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
4.33/5 (3 votes)
See more:
I have two listbox in windows Form c#, the first one has all valid rooms at this time & the 2nd has the current rooms reserved to the Guest, & the user can change this data by transfer between this listboxex.

as example:

list1: 1d ,5d ,6d , 1r, 12r

list2: 2d, 4d

the user can delete 2d and put instead of it 6d.



what I need how can I read all data from list2 after user update it, & use this to update my table in sql server.

Thanks for help
Posted

listbox2.Items is a collection of all of the items in the ListBox. I would cycle through the collection and update the database with each item.

C#
foreach (string item in listBox2.Items)
{
    // same the item to the database

}
 
Share this answer
 
v2
C#
string TimeslotItems = "";
foreach (ListItem item in listBox2.Items)
{
TimeslotItems += item.ToString() + ","; // /n to print each item on new line or you omit /n to print text on same line
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900