Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

How to get string from database, and if the strings are match in the sense make the checkedlistbox checkeditems.

If possible I need code...

I'm using WinForms

Thanks in Advance...
Posted
Updated 25-Jan-12 4:01am
v2
Comments
BillWoodruff 25-Jan-12 8:29am    
When you have made an initial attempt, yourself, post the code here, and then we can help you.

1 solution

Use below method
-----------------
C#
DataTable dt = GetTables(); ;
           string listItems=String.Empty;
           dt.AsEnumerable().ToList<DataRow>().ForEach(Obj => listItems += ","+Obj["ColName"].ToString());
           listItems = listItems + ",";
           for (int i = 0; i < objchListBox.Items.Count; i++)
           {
               if (listItems.Contains("," + objchListBox.Items[i].ToString() + ","))
                   objchListBox.SetItemChecked(i, true);
               else
                   objchListBox.SetItemChecked(i, false);
           }
 
Share this answer
 
v2
Comments
fjdiewornncalwe 25-Jan-12 10:02am    
It looks like the answer the OP is looking for.

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