Hallo Telerik Team,
I would like to know how I add a list of images to a ListView as Icon View. The path images are in a List<string> and they are into:
C://Documents/Pic/.
How can I do that? The images paths are saved in a dataTable in a database.
Thank you very much.
Best regards,
Alfonsina Mello
I would like to know how I add a list of images to a ListView as Icon View. The path images are in a List<string> and they are into:
C://Documents/Pic/.
How can I do that? The images paths are saved in a dataTable in a database.
Thank you very much.
Best regards,
Alfonsina Mello
5 Answers, 1 is accepted
0
Hi Alfonsina,
Thank you for contacting us.
You need to iterate through the paths and create items with that image:
I hope this helps. If you have any other questions, feel free to write back.
Regards,
Ivan Todorov
the Telerik team
Thank you for contacting us.
You need to iterate through the paths and create items with that image:
foreach
(
string
fileName
in
files)
// files is List<string>
{
ListViewDataItem item =
new
ListViewDataItem();
item.Image = Image.FromFile(fileName);
this
.radListView1.Items.Add(item);
}
I hope this helps. If you have any other questions, feel free to write back.
Regards,
Ivan Todorov
the Telerik team
0
Alfonsina
Top achievements
Rank 1
answered on 14 Dec 2012, 01:43 PM
Hallo Telerik Team,
Thank you very much. It has worked. Now I have another question. I have my images in the RadListView and when
I click one image, it shows no selection. how can I do that. I would like to select the images.
Thank you very much!
Best regards,
Alfonsina
Thank you very much. It has worked. Now I have another question. I have my images in the RadListView and when
I click one image, it shows no selection. how can I do that. I would like to select the images.
Thank you very much!
Best regards,
Alfonsina
0
Hello Alfonsina,
You should not lose the selection highlight when your items have images assigned unless the images are overlaying the background. Please make sure your images have a transparent background. If you continue experiencing difficulties, please open a new support ticket and attach a project which demonstrates the issue. This will let me investigate it and provide you with further support.
Do not hesitate to contact us if you need further assistance.
Greetings,
Ivan Todorov
the Telerik team
You should not lose the selection highlight when your items have images assigned unless the images are overlaying the background. Please make sure your images have a transparent background. If you continue experiencing difficulties, please open a new support ticket and attach a project which demonstrates the issue. This will let me investigate it and provide you with further support.
Do not hesitate to contact us if you need further assistance.
Greetings,
Ivan Todorov
the Telerik team
0
Oscar
Top achievements
Rank 2
answered on 21 Feb 2014, 03:40 PM
Hi, this works, but how can I strech the Image ? there is no a strech true, or item.Image.Strech property, I use aligment, but it doesn't work in 2013 q3 tha I am testing, in 2013 q1, it works,
here is my code:
ListViewDataItem item = new ListViewDataItem(e.fileName);
item.Text = e.fileName;
item.ImageAlignment = ContentAlignment.TopCenter;
item.TextImageRelation = TextImageRelation.TextBeforeImage;
item.TextAlignment = ContentAlignment.BottomCenter;
Image img = Image.FromFile(e.fileName);
radListViewMedia.Items.Add(item);
here is my code:
ListViewDataItem item = new ListViewDataItem(e.fileName);
item.Text = e.fileName;
item.ImageAlignment = ContentAlignment.TopCenter;
item.TextImageRelation = TextImageRelation.TextBeforeImage;
item.TextAlignment = ContentAlignment.BottomCenter;
Image img = Image.FromFile(e.fileName);
radListViewMedia.Items.Add(item);
0
Hello Oscar,
Thank you for writing.
To make an image stretch, you should use the VisualItemFormatting event and set the VisualItem's ImageLayout property:
I hope this helps.
Regards,
Stefan
Telerik
Thank you for writing.
To make an image stretch, you should use the VisualItemFormatting event and set the VisualItem's ImageLayout property:
void
radListView1_VisualItemFormatting(
object
sender, ListViewVisualItemEventArgs e)
{
e.VisualItem.ImageLayout = ImageLayout.Stretch;
}
I hope this helps.
Regards,
Stefan
Telerik