The main list of items uses a ListView (default View property should be
View.Details). To get the icons you'll need two ImageList controls -
one for small and one for large icons - setting the LargeImageList and
SmallImageList accordingly.
Use the overload of listView.Items.Add which allows you to pass in
string of subitems and and image index for different images
public class Form1 : Form
{
private System.ComponentModel.IContainer components = null;
private System.Windows.Forms.ListView listView;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ImageList imageList;
public Form1()
{
InitializeComponent();
listView.Items.Add(new ListViewItem(new string[] {"Add
hardware", "Installs and troubleshoots"}, 0));
listView.Items.Add(new ListViewItem(new string[] { "Admin
tools", "Configure" }, 1));
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new
System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.listView = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.imageList = new
System.Windows.Forms.ImageList(this.components);
this.SuspendLayout();
//
// listView
//
this.listView.Columns.AddRange(new
System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.listView.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView.LargeImageList = this.imageList;
this.listView.Location = new System.Drawing.Point(4, 4);
this.listView.Name = "listView";
this.listView.Size = new System.Drawing.Size(284, 265);
this.listView.SmallImageList = this.imageList;
this.listView.TabIndex = 0;
this.listView.UseCompatibleStateImageBehavior = false;
this.listView.View = System.Windows.Forms.View.List;
this.listView.DoubleClick += new
System.EventHandler(this.listView_DoubleClick);
//
// columnHeader1
//
this.columnHeader1.Text = "Name";
this.columnHeader1.Width = 115;
//
// columnHeader2
//
this.columnHeader2.Text = "Comments";
this.columnHeader2.Width = 153;
//
// imageList
//
this.imageList.ImageStream =
((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
this.imageList.TransparentColor =
System.Drawing.Color.Transparent;
this.imageList.Images.SetKeyName(0, "");
this.imageList.Images.SetKeyName(1, "ActualSize.bmp");
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.listView);
this.Name = "Form1";
this.Padding = new System.Windows.Forms.Padding(4);
this.Text = "Form1";
this.ResumeLayout(false);
}
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void listView_DoubleClick(object sender, EventArgs e)
{
if ((int)listView.View < 4)
{
listView.View = (View)(listView.View + 1);
}
else
{
listView.View = 0;
}
}
}