This is a migrated thread and some comments may be shown as answers.

display list of thumbnail image

4 Answers 581 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Truong
Top achievements
Rank 1
Truong asked on 03 Jun 2012, 06:33 AM
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

4 Answers, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 06 Jun 2012, 04:19 PM
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 >>
0
Truong
Top achievements
Rank 1
answered on 13 Jun 2012, 04:22 AM
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?
0
Accepted
Ivan Todorov
Telerik team
answered on 14 Jun 2012, 07:36 AM
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 >>
0
Truong
Top achievements
Rank 1
answered on 15 Jun 2012, 02:41 AM
Dear Ivan,

Thanks for your support.
Tags
ListView
Asked by
Truong
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Truong
Top achievements
Rank 1
Share this question
or