We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Bind ImageList to SfListView

Thread ID:

Created:

Updated:

Platform:

Replies:

149358 Nov 22,2019 06:07 PM UTC Dec 10,2019 12:16 PM UTC WinForms 3
loading
Tags: SfListView
Patric Gehl
Asked On November 22, 2019 06:07 PM UTC

Hello,

i use VS2019 and SF Version 17.3 and .Net Framework 4.7.2.

I want to Display an ImageList in a sfListView and try to bind it as a DataSource.

But this is not working. So what is the best way to Display a List of Images with a text and what is the best Control?

I already try to use the sfDataGrid; but here the Problem is that the Images get 'transformed' or shrinked if only a part of a row is visible (the cell try to press the whole Image in the visible part of the cell; so if the size of the Image is 100 x 100 but only ten percent of the cell is visible, the whole Image is shrink to that ten percent). If you scroll so the whole cell is visible you see the original size after a refresh.

But may be there are some controls in the Collection; i Need to Display an List of Images with text; Always 5 to 10 Images at once and to scroll to the following Images. And a single selection.

Any ideas?

Thanks

Patric 

Kanniyappan Panneer Selvam [Syncfusion]
Replied On November 25, 2019 11:08 AM UTC

Hi Patric Gehl, 
 
Thanks for contacting Syncfusion support. 
 
We checked your query “Display an List of Images with text in SfListView” and we can achieve your requirement by using DrawItem event of the  SfListView. We have prepared the  sample as per your requirement, In the attached sample, we have added the image for an item using e.Image (added image based on item index) . Please find the code snippet, screenshot, sample and documentation link for the same.  
  
Code Snippet: 
 
private void SfListView1_DrawItem(object sender, Syncfusion.WinForms.ListView.Events.DrawItemEventArgs e) 
        { 
            e.Image = Image.FromFile(@"..\..\mail.png"); 
            
            if (e.ItemIndex == 5) 
            { 
                e.Image = Image.FromFile(@"..\..\delete.png"); 
            } 
            if (e.ItemIndex == 6) 
            { 
                e.Image = Image.FromFile(@"..\..\bin.png"); 
            } 
            e.ImageAlignment = ContentAlignment.MiddleLeft; 
             
        } 
 
Screenshot: 
 
 
 
 
 
Please us know more details about the requirement if we have misunderstood your query. 
 
Regards, 
Kanniyappan P 
 


Patric Gehl
Replied On December 9, 2019 05:43 PM UTC

Hello Kanniyappan sorry for my late Reply,

since ImageList is a Collection, my hope was that the sfListView could bind this Collection. But as far as i understood your answer, i must loop over all Elements in the Collection and use them in the 'drawItem Event.

I used an other solution for this Problem. But thanks for your support.

Patric

Niranjan Kumar Gopalan [Syncfusion]
Replied On December 10, 2019 12:16 PM UTC

Hi Patric Gehl, 
 
Thanks for your update. 
 
Can you please share us your solution that you have for SfListView? It will be helpful for us to update in our documentation or Knowledge Base. Please let us know if you have any queries. 
 
Regards, 
Niranjan Kumar 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon