RadListBox with images

4 posts, 0 answers
  1. Warren
    Warren avatar
    17 posts
    Member since:
    May 2008

    Posted 28 Aug 2008 Link to this post

    How do I add images to a radlistbox?

    This is what I have so far:

        Me.RadListBox1.DisplayMember = "LocationStatus" 
        Me.RadListBox1.ValueMember = "LocationStatusId" 
        Me.RadListBox1.ImageList = Me.ImageList1 



  2. Angel
    Admin
    Angel avatar
    121 posts

    Posted 29 Aug 2008 Link to this post

    Hello Warren,

    You have to set either the ImageIndex or ImageKey property for each item in the listbox. This is done through the property grid.

    Let us know if you had something different in mind.

     
    Sincerely yours,
    Angel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Warren
    Warren avatar
    17 posts
    Member since:
    May 2008

    Posted 29 Aug 2008 Link to this post

    I'm setting my datasource during runtime

    Me.RadListBox1.DataSource = OTS.GetLocationStatus(True)


    How do I set the ImageIndex or ImageKey in code?
  5. Angel
    Admin
    Angel avatar
    121 posts

    Posted 01 Sep 2008 Link to this post

    Hi Warren,

    Here is a sample code that sets the first image from the image list to every even item, while the second image is set to the odd items:

    Dim i As Integer = 0 
    Do While i < Me.RadListBox1.Items.Count 
        Dim item As RadListBoxItem = CType(Me.RadListBox1.Items(i), RadListBoxItem)  
        If (i Mod 2) = 0 Then  
            item.ImageIndex = 0 
        Else  
            item.ImageIndex = 1 
        End If  
        i += 1  
    Loop 

    You may also consider the TextImageRelation, TextAlignment and ImageAlignment properties of RadListBoxItem.

     
    Greetings,
    Angel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top