zy62_列表视图实现图标的排列,点击跳转,以及升降序

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;
         }
     }
 }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值