Home > Net >  How to write text in Listview
How to write text in Listview

Time:07-07

This is my code to write text with a image in list view.

            var imageList = new ImageList();
            Image image = Image.FromFile("ABC.png");
            imageList.Images.Add("ABC", image);
            listView1.LargeImageList = imageList;
            var listViewItem = listView1.Items.Add("text with image");
            listViewItem.ImageKey = "ABC";

The issue I am facing is the text and the image should come in one row but currently they are coming in multiple rows.

enter image description here

CodePudding user response:

Thanks to @Klaus Gütter I was able to solve this.

I changed the view from LargeIcons to SmallIcons.

Also did change this line in the code.

 listView1.SmallImageList = imageList;
  • Related