I have encountered a small problem with ListView in c# winforms. The purpose of my application was to be able to read in dll files in Windows (Post to read in Windows dll files), I made the two biggest Windows libraries (imageres.dll & shell32.dll). That's when I switched to pifmgr.dll (contains 38 icons), it displays the last icon in the dll file until it reaches the number of items that imageres.dll contains. In the post I showed earlier, the code contained a loop so here is the loop that is made of the code:
for (int j = 0; j < this.imageList1.Images.Count; j++)
{
ListViewItem item = new ListViewItem();
item.ImageIndex = j;
this.listView1.Items.Add(item);
}
But as I said above, I'm going from a dll file of 334 icons to 38 icons so I need to add a code that will allow me to delete the excess items. If you want to see the result of going from a 334 icons dll file to a 38 icons one, here is the result: 334 icons dll file to 38 one
Thanks for helping me.
Edit 1: Is there a way that we can fix the big hole above all the pictures because it's really annoying for me and those who will use this application. Is there a way to fix this?
Edit 2: The form is taking 5 seconds to load and it's a lot of time for just loading one form. I really don't know how to load it faster than 5 secs.
Edit 3: The loop and the images initializing are in the form constructor
public YourFormName()
{
InitializeComponent();
string dllName = "imageres.dll";
ltView.SmallImageList = imgListImageres;
ltView.LargeImageList = imgListImageres;
cbDllName.Texts = @"%systemroot%\system32\imageres.dll";
this.Icon = IconExtractor.IconExtractor.Extract("imageres.dll", 24, true);
//Configuring the images like the above code...
ltView.BeginUpdate();
ltView.Clear();
for (int i = 0; i < this.imgListImageres.Images.Count; i++)
{
ListViewItem item = new ListViewItem();
item.ImageIndex = i;
this.ltView.Items.Add(item);
}
ltView.EndUpdate();
LoadTheme();
}
I have tried everything but without success, the form still loads slowly. You can see on the code above, I put ltView.BeginUpdate(); and after the loop ltView.EndUpdate(); as I had seen in the Microsoft doc. So the form needs to load faster than that because 4-5 seconds to load a single form is still a long time.