display list of thumbnail image

5 posts, 1 answers
  1. Truong
    Truong avatar
    9 posts
    Member since:
    Sep 2011

    Posted 03 Jun 2012 Link to this post

    I have trying to display list of thumbnail image use ListView. I have followed the guide on documentation  http://www.telerik.com/help/winforms/listview-custom-items.html  but my thumbnail list does not display correct. Please view result and my code.

    Public Class MyCustomVisualItem
        Inherits SimpleListViewVisualItem
     
        Private imageelement As RadImageItem
     
        Private stackLayout As StackLayoutPanel
     
        Protected Overrides Sub CreateChildElements()
            MyBase.CreateChildElements()
     
            Me.stackLayout = New StackLayoutPanel()
            Me.stackLayout.Orientation = Orientation.Horizontal
            Me.stackLayout.EqualChildrenWidth = True
     
            Me.imageelement = New RadImageItem
            ' Me.imageelement.
            Me.imageelement.MinSize = New Size(120, 120)
            Me.stackLayout.Children.Add(Me.imageelement)
     
            Me.Children.Add(Me.stackLayout)
        End Sub
     
        Protected Overrides Sub SynchronizeProperties()
            MyBase.SynchronizeProperties()
     
            Me.Text = ""
            Dim myId As Decimal = CType(Me.Data.DataBoundItem, Decimal)
            Me.imageelement.Image = loadThumbnail(myId)
            'Me.contentElement.Text = Convert.ToString(Me.Data("Name"))
            'Me.buttonElement1.Text = "Call " + Convert.ToString(Me.Data("Phone"))
            'Me.buttonElement2.Text = "Fax " + Convert.ToString(Me.Data("Fax"))
        End Sub
     
        Protected Overrides ReadOnly Property ThemeEffectiveType() As Type
            Get
                Return GetType(SimpleListViewVisualItem)
            End Get
        End Property
        Private Function loadThumbnail(ByVal iD As Decimal) As Image
            Dim temp As Byte() = (From cont In Program.travel_context.images _
                                Where cont.image_id = iD _
                                Select cont.icon).First
     
            Dim temp_image As Image = Image.FromStream(New MemoryStream(temp))
     
            Return temp_image
        End Function
    End Class

  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 06 Jun 2012 Link to this post

    Hi Truong,

    Thank you for writing.

    You are getting this result because of the ItemSize settings of your RadListView. To overcome this, you can either increase the height of the items by modifying the ItemSize property of RadListView or you can enable the AllowArbitraryItemHeight property to allow the items to size according to their content.

    More information about different sizing modes of the items in RadListView can be found in this help article.

    I hope this will help you. Should you have any additional questions, do not hesitate to ask.

    Kind regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Truong
    Truong avatar
    9 posts
    Member since:
    Sep 2011

    Posted 12 Jun 2012 Link to this post

    Dear Ivan,

    I have followed your guide and ti working properly. But I have one more issue. I can not select listview item using mouse. I just move to the next item using keyboard only. How can I can select any item by click on it?
  5. Answer
    Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 14 Jun 2012 Link to this post

    Hello Truong,

    You cannot select an item with the mouse, because the image element you have put over each item receives the mouse input. To overcome this, you need to set the following two properties of your image element:
    Me.imageelement.ShouldHandleMouseInput = False
    Me.imageelement.NotifyParentOnMouseInput = True

    I hope this will help you. Feel free to ask if you have any additional questions.

    Kind regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  6. Truong
    Truong avatar
    9 posts
    Member since:
    Sep 2011

    Posted 14 Jun 2012 Link to this post

    Dear Ivan,

    Thanks for your support.
Back to Top
UI for WinForms is Visual Studio 2017 Ready