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

Winforms: Resizing the Image with item size in RadListView

2 Answers 472 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Hashim
Top achievements
Rank 1
Hashim asked on 25 Feb 2020, 06:36 AM

Hi,

I am working on RadListView, reading files from folder, and display file in the folder along with icon(image), Issue is the icon doesn't resize according to the item size. Code is given below

           

the result is as following:

Kindly guide me how can I display the image according to the size of item;

Regards

 

2 Answers, 1 is accepted

Sort by
0
Hashim
Top achievements
Rank 1
answered on 25 Feb 2020, 06:39 AM

Code is as given below:

            radListview.EnableSorting = true;

            radListview.EnableColumnSort = true;

            radListview.ViewType = ListViewType.DetailsView;
            radListview.Columns.Add("File Name");
            radListview.Columns.Add("Path");
            radListview.Columns.Add("Size (KB)");
            radListview.Columns.Add("Date");
            string[] files = Directory.GetFiles(@"D:\Codes\Images\orignal");
            foreach (string file in files)
            {
                FileInfo info = new FileInfo(file);
                ListViewDataItem item = new ListViewDataItem();
                radListview.Items.Add(item);
                item[0] = info.Name;
                item[1] = file;
                item[2] = (info.Length/1024);
                item[3] = info.LastWriteTime;
                var img = Image.FromFile("zip.png");
                item.Image = img;
            }

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 27 Feb 2020, 02:00 PM
 

Hello, Hashim,

According to the provided screenshot, it seems that the image is big enough and it doesn't fit in the available space for the cell element in the DetailsView. In order to display the whole image, I can suggest you two options:

- Set the AllowArbitraryItemHeight property to true. Thus, the row's height will be adjusted to display the whole image:

- Subscribe to the CellFormatting event and set the CellElement.ImageLayout property to Zoom. Thus, the row's height will remain unchanged but the image will be shrunk to display the entire content: 

        private void radListView1_CellFormatting(object sender, ListViewCellFormattingEventArgs e)
        {
            e.CellElement.ImageLayout = ImageLayout.Zoom;
        }

 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ListView
Asked by
Hashim
Top achievements
Rank 1
Answers by
Hashim
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or