0

i have a checked list box as one of my controls in my code what happens is when i click on the checked list box the item clicked in the checked list box is supposed to be added to a text box, and my code is now doing that however when a user clicks an item item and then unclicks it it becomes a problem.pliz help the code is below.

If txtSQL.Text = "" Then
            txtSQL.Text = chlTableCols.GetItemText(chlTableCols.SelectedItem.ToString)
        Else
            txtSQL.Text = txtSQL.Text.ToString + ("," + chlTableCols.GetItemText(chlTableCols.SelectedItem))
        End If
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by tendaimare
0

Hi!

Try this:

If txtSQL.Text = "" Then
            txtSQL.Text = chlTableCols.GetItemText(chlTableCols.SelectedItem.ToString)
        Else
            If Not (txtSQL.Text.Contains(chlTableCols.SelectedItem.ToString)) Then
                txtSQL.Text = txtSQL.Text & "," & chlTableCols.GetItemText(chlTableCols.SelectedItem)
            Else
                txtSQL.Text = "," & txtSQL.Text
                txtSQL.Text = txtSQL.Text.Replace("," & chlTableCols.GetItemText(chlTableCols.SelectedItem), "")
                txtSQL.Text = txtSQL.Text.TrimStart(",")
            End If
        End If
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.