Bind ImageList to SfListView
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
SIGN IN To post a reply.
3 Replies
KP
Kanniyappan Panneer Selvam
Syncfusion Team
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:
Sample: https://www.syncfusion.com/downloads/support/forum/149358/ze/SfListView_DrawImage(1)-288934841.zip
Documentation Link : https://help.syncfusion.com/windowsforms/sflistview/appearance#customizing-item-appearance
Please us know more details about the requirement if we have misunderstood your query.
Regards,
Kanniyappan P
PG
Patric Gehl
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
NI
Ninja
Syncfusion Team
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
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
PG Patric Gehl
- Nov 22, 2019 06:07 PM UTC
- Dec 10, 2019 12:16 PM UTC