下面我用C#写了个类QQ界面
效果图:
下面来介绍实现过程:
一、首先放三个Button,Text分别为好友,朋友,陌生人,接着放一个ListView 再放一个ImageList设置其Items将图片加载到这个元素集合中
二、并设置ListView的属性LargeImageList为imagelist实现ImageList里面的图片集合与ListView相关联
三、好啦界面基本设计好现在来看后台代码。目标实现:点击Button按钮有不同缩放效果
先认识两个函数:SendToBack()和BringToFront()函数
SendToBack() 将控件移到 Z 顺序的后面。
BringToFront()将控件移到 Z 顺序的前面
下面是完整代码不解释:
private void Form1_Load(object sender, EventArgs e)
{
listView1.Clear();//将listView中的元素清空
listView1.LargeImageList = imageList1;
listView1.Items.Add("小张","小张",0);
listView1.Items.Add("小李","小李",1);
listView1.Items.Add("小王","小王",2);
listView1.Items.Add("小周","小周",3);
}
private void button1_Click(object sender, EventArgs e)
{
listView1.Dock = DockStyle.None;
button1.Dock = DockStyle.Top;
button3.Dock = DockStyle.Bottom;
button2.SendToBack();
button2.Dock = DockStyle.Bottom;
listView1.BringToFront();
listView1.Dock = DockStyle.Bottom;
listView1.Clear();
listView1.LargeImageList = imageList1;
listView1.Items.Add("小张", "小张", 0);
listView1.Items.Add("小李", "小李", 1);
listView1.Items.Add("小王", "小王", 2);
listView1.Items.Add("小周", "小周", 3);
}
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);
listView1.Items.Add("小罗","小罗",4);
listView1.Items.Add("小花","小花",5);
}
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("小张","小张",0);
listView1.Items.Add("小王","小王",2);
listView1.Items.Add("小罗","小罗",4);
}