实现过程
(1)创建一个项目,将其命名为Ex01_17,默认窗体为Form1。
(2)在窗体上添加Button 控件、ListView 控件和ImageList 控件。设置L
istView 控件的ImageList 属性为ImageList 控件。
SendToBack 方法
http://msdn.microsoft.com/zh-cn/library/microsoft.office.tools.excel.controls.button.sendtoback%28v=VS.90%29.aspx#Y0
(1)创建一个项目,将其命名为Ex01_17,默认窗体为Form1。
(2)在窗体上添加Button 控件、ListView 控件和ImageList 控件。设置L
istView 控件的ImageList 属性为ImageList 控件。
(3)主要程序代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Ex01_07
{
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("小猪", "小猪", 0);
listView1.Items.Add("小狗", "小狗", 1);
listView1.Items.Add("娇娇", "娇娇", 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("北风", "北风", 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("冰雨", "冰雨", 5);
}
private void Form1_Load(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("小猪", "小猪", 0);
listView1.Items.Add("小狗", "小狗", 1);
listView1.Items.Add("娇娇", "娇娇", 2);
}
}
}