Principle: N ListView controls, N button controls, and then controls the Dock property of the ListView and button controls
As follows:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace QQ
{
public partial class Form1:form
{
public Form1 ()
{
InitializeComponent ();
}
private void Button1_Click (object sender, EventArgs e)
{
listview1.dock = Dockstyle.none;
button1. Dock = Dockstyle.top;
button2. Dock = Dockstyle.bottom;
Button3. SendToBack ();
Button3. Dock = Dockstyle.bottom;
Listview1.bringtofront ();
listview1.dock = Dockstyle.bottom;
listview1.clear ();
listView1.Items.Add ("Piggy", "Piggy", 0);
listView1.Items.Add ("Puppy", "Puppy", 1);
listView1.Items.Add ("Jiao jiao", "Jiao jiao", 2);
}
private void Form1_Load (object sender, EventArgs e)
{
listview1.clear ();
listview1.largeimagelist = ImageList1;
listView1.Items.Add ("Piggy", "Piggy", 0);
listView1.Items.Add ("Puppy", "Puppy", 1);
listView1.Items.Add ("Jiao jiao", "Jiao jiao", 2);
}
private void Button2_Click (object sender, EventArgs e)
{
listview1.dock = Dockstyle.none;
button2. Dock = Dockstyle.top;
button1. SendToBack ();
Button1. Dock = Dockstyle.top;
Button3. Dock = Dockstyle.bottom;
listview1.dock = Dockstyle.bottom;
listview1.clear ();
ListView1.Items.Add ("North Wind", "North Wind", 3);
}
private void Button3_Click (object sender, EventArgs e)
{
listview1.dock = Dockstyle.none;
Button3. SendToBack ();
Button3. Dock = Dockstyle.top;
button2. SendToBack ();
button2. Dock = Dockstyle.top;
button1. SendToBack ();
button1. Dock = Dockstyle.top;
listview1.dock = Dockstyle.bottom;
listview1.clear ();
listView1.Items.Add ("Ice Rain", "Ice Rain", 5);
}
}
}
Article Source: http://www.cnblogs.com/ziyiFly/archive/2008/09/11/1288820.html