Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone ,

i need one help, what i want is that there is a checklistbox i want to create a lable of items checked in checkedboxlist i have writen this code :

VB
Private Sub CreatControls()
        If chkcolmlst.CheckedItems.Count > 0 Then
            Dim lbl(100) As Label
            For i As Integer = 0 To chkcolmlst.Items.Count - 1
                lbl(i) = New Label()
                newform.Controls.Add(lbl(i))
                lbl(i).Text = chkcolmlst.Text
                lbl(i).Location = New Point(125, 135 + (i * 200))
            Next
        End if

now problem is that it is creating a lable but it is creating a lables of same name what i select the last item in checkedlistbox.

please help...............
Posted
Updated 17-Aug-14 21:06pm
v2

1 solution

A fairly simple issue, you put the same text into every label:
VB
lbl(i).Text = chkcolmlst.Text

Presumably what you really want is some detail from the item indexed by the current value of i.
 
Share this answer
 
Comments
Member 11014751 18-Aug-14 3:52am    
so what do i code in replace of this line?
Richard MacCutchan 18-Aug-14 9:01am    
Well since we don't know what you want in the label we cannot tell you what to code.
Member 11014751 18-Aug-14 9:07am    
I want the selected item Text in lable

like there are 3 items in Checkbox A,B,C
i selected A&C now i want to create lable named A&C
Member 11014751 18-Aug-14 4:43am    
Please Anyone?
Member 11014751 18-Aug-14 9:09am    
in this code it is working like if i select A&C
it makes the two lable named "A" it is now creating second lable with name C

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