Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to populate the checkedlistbox from dataset

Status
Not open for further replies.

Kingkumar

Programmer
Jan 21, 2003
167
US
Hi i need to create a checkedlistbox and populate it from teh database in two steps.
First i need to get teh list of all the available options (like the books available in store) and tehn depending on each user check the checkboxes out of all the books in the store )
i am able to populate the checkbox with all the available books but how to only check particular checkboxes after reading form teh database the user books
please help
thanks
regards,
king
 
You can fill the CheckedListBox from a DataSet by iterating through the DataSet rows and Adding the items.
Code:
For i As Integer = 0 To ds1.Tables(0).Rows.Count - 1
    CheckedListBox1.Items.Add(ds1.Tables(0).Rows(i).Item(0))
Next

Then, you can check items in the CheckedListBox by using a variable to select the item.
Code:
CheckedListBox1.SelectedItem = stringVariable
CheckedListBox1.SetItemCheckState(CheckedListBox1.SelectedIndex, CheckState.Checked)

Andrea
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top