// Create a new ListView object. ListView myListView = new ListView(); // Set the ListView control to display in tile format. myListView.View = View.Tile; // Add items to the ListView. myListView.Items.AddRange(new ListViewItem[] { new ListViewItem("Item 1"), new ListViewItem("Item 2"), new ListViewItem("Item 3") }); // Call the CreateControl method to create the control. myListView.CreateControl(); // Add the ListView control to a form. this.Controls.Add(myListView);
// Find an existing ListView control on the form. ListView myListView = (ListView)this.Controls.Find("myListView", true)[0]; // Call the CreateControl method to recreate the control. myListView.CreateControl();This example finds an existing ListView control on the form by its name and calls the CreateControl method to recreate the control. This may be required if the control has been removed or if changes have been made to the control that require it to be recreated. Package library: System.Windows.Forms.ListView