1.列表视图重要属性和事件
Activation:单击/双击事件发生
Items:添加项目
2.完整程序理解列表视图
列表试图实现图标的排列,点击跳转,以及升降序
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
browseListView.View = View.Tile;
}
private void button2_Click(object sender, EventArgs e)
{
browseListView.View = View.List;
}
private void button3_Click(object sender, EventArgs e)
{
browseListView.View = View.LargeIcon;
}
private void button4_Click(object sender, EventArgs e)
{
browseListView.View = View.SmallIcon;
}
private void button5_Click(object sender, EventArgs e)
{
browseListView.View = View.Details;
}
private void browseListView_ItemActivate(object sender, EventArgs e)
{
string myDoc = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);//获取系统默认文件夹位置
string myMus = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
string myPic = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
switch (browseListView.SelectedIndices[0])
{
case 0: System.Diagnostics.Process.Start(myDoc); break;
case 1: System.Diagnostics.Process.Start(myMus); break;
case 2: System.Diagnostics.Process.Start(myPic); break;
case 3: System.Diagnostics.Process.Start("ms-edge:https://cn.bing.com/"); break;
case 4: System.Diagnostics.Process.Start("Notepad"); break;
case 5: System.Diagnostics.Process.Start("calc"); break;
}
}
private void browseListView_ColumnClick(object sender, ColumnClickEventArgs e)
{
if(browseListView.Sorting == SortOrder.None)
{
browseListView.Sorting= SortOrder.Ascending;
}
else if(browseListView.Sorting==SortOrder.Ascending)
{
browseListView.Sorting= SortOrder.Descending;
}
else
{
browseListView.Sorting=SortOrder.Ascending;
}
}
}