I’m trying to use a System.Windows.Forms.ListView control to display an image and text, I am using Microsoft Visual Studio Professional 2022, the language is c# which is very new to me. I have lots of experience with C/C++ and Java.
Code to set-up in the dialog constructor:
mlstImg.Images.Add(Resources.EMPTY);
mlstImg.Images.Add(Resources.MIXED);
mlstImg.Images.Add(Resources.DOWN);
mlstImg.Images.Add(Resources.UP);
this.lvClients.SmallImageList = mlstImg;
this.lvClients.LargeImageList = mlstImg;
this.lvClients.View = View.Details;
I have put a ListView control onto a dialog, this is from the Designer.cs:
this.lvClients.HideSelection = false;
this.lvClients.Location = new System.Drawing.Point(7, 26);
this.lvClients.MultiSelect = false;
this.lvClients.Name = "lvClients";
this.lvClients.Size = new System.Drawing.Size(383, 532);
this.lvClients.TabIndex = 43;
this.lvClients.UseCompatibleStateImageBehavior = false;
And the code here is a sample of the code that adds items:
this.lvClients.Items.Add(new ListViewItem {
ImageIndex = mcintEmptyImgIdx
, Text = strTmpClient
});
I have added this after the source that populates the list view:
Console.WriteLine(string.Format("this.lvClients.Items.Count: {0}"
, this.lvClients.Items.Count));
The output in the console:
this.lvClients.Items.Count: 199
I see nothing in the ListView, the scrollbar indicates there is content but nothing is visible.