language: vb.net
environment: windows forms
.net : v1.1
i am having a checkedlistbox control that display document category such as text, image, video, audio etc. these values are coming from database. when a user clicks any of the above values and saves the form, the item's "value" is getting saved in database. and when a user logs back in, his/her previously checked value items should be shown as checked.
Everything is working fine except a checked item is not showing up as checked in the form when i try to do it programmitacall y. i know that the code is actually setting the item's checked property to true because itemCheck event gets fired immediately after my code but it just cant show it as checked in the form. here is my vb.net code
do you have any idea as to why form is not showing up checkedlistbox' s item as "checked" in the final output??
environment: windows forms
.net : v1.1
i am having a checkedlistbox control that display document category such as text, image, video, audio etc. these values are coming from database. when a user clicks any of the above values and saves the form, the item's "value" is getting saved in database. and when a user logs back in, his/her previously checked value items should be shown as checked.
Everything is working fine except a checked item is not showing up as checked in the form when i try to do it programmitacall y. i know that the code is actually setting the item's checked property to true because itemCheck event gets fired immediately after my code but it just cant show it as checked in the form. here is my vb.net code
Code:
sub showCategory() dim dt as new datatable dt=getDocumentCategory() ' returns doc category as datatable Dim catarr As New ArrayList catarr = getCheckedCategory(userid) 'array of previously checked items catarr.TrimToSize() Me.SuspendLayout() clbCategory.DataSource = dt.DefaultView clbCategory.DisplayMember = "category_name" clbCategory.ValueMember = "id" If companyid > 0 Then For i As Integer = 0 To clbCategory.Items.Count - 1 Dim row As DataRowView = clbCategory.Items.Item(i) If catarr.IndexOf(row(0)) >= 0 Then clbCategory.SetItemChecked(i, True) '<-- this line is setting the item's checked property to true and itemCheck event is getting fired as it should but windows form is not showing up this item as checked. clbCategory.SetSelected(i, True) End If Next End If Me.ResumeLayout() end sub
Comment