Home Forums WinForms controls Other WinForms controls Smartcheckedlistbox

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18128 |

    How do you acces the checked property of each item in a Smartckedlistbox?
    Suppose I have the following code…

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles MyBase.Load

    Dim xInt As Integer

    For xInt = 1 To 10
    SmartCheckedListBox1.Items.Add(xInt)
    Next

    End Sub

    When the form loads it fills a smartcheckedlistbox with 10 items, now when the user presses a button the form should display a message whith the items in the smartcheckedlistbox which checkbox item are in a checked state (Did I make myself clear?). Thanx in advance for the help!

    Imported from legacy forums. Posted by cursositca (had 2427 views)

    User (Old forums)
    Member
    Post count: 23064

    You have to verify the Checked property on the item. However, since you are creating the items at runtime, you don’t have a direct reference to the item, so you will need to cast the item to a CheckedListBoxItem to get the property :

    C#
    ( ( CheckedListBoxItem )smartCheckedListBox1.Items[ 0 ]).Checked

    VB
    CType( SmartCheckedListBox1.Items( 0 ), CheckedListBoxItem ).Checked

    You need to cast it because the Items collection can contain other type of items, not just a CheckedListBoxItem. BTW, it is part of the Xceed.SmartUI.Controls.CheckedListBox namespace.

    Imported from legacy forums. Posted by André (had 2879 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.