zoukankan      html  css  js  c++  java
  • ListView

     public partial class Form1 : Form
        {
            public Form1()
            {
                //InitializeComponent();
                InitializeComponent();
                this.listView1.Columns.Add("列标题1", 120, HorizontalAlignment.Left);//新增列与行
                this.listView1.Columns.Add("列标题2", 120, HorizontalAlignment.Left);
                this.listView1.Columns.Add("列标题3", 120, HorizontalAlignment.Left);
                for (int i = 0; i < 10; i++)   //添加10行数据  
                {
                    ListViewItem lvi = new ListViewItem();
    
                    lvi.ImageIndex = i;     //通过与imageList绑定,显示imageList中第i项图标  
    
                    lvi.Text = "subitem" + i;//从0开始记
    
                    lvi.SubItems.Add("第2列,第" + i + "");//显示内容为。。。
    
                    lvi.SubItems.Add("第3列,第" + i + "");
    
                    this.listView1.Items.Add(lvi);
    
                }
               lvTabInfo.Clear();
             lvTabInfo.View = View.Details;
                this.lvTabInfo.Columns.Add("栏目", 100, HorizontalAlignment.Center);//在新的listview里新建的列和行
                this.lvTabInfo.Columns.Add("详细信息", 100, HorizontalAlignment.Center);
    
            }
           
    
            private void button1_Click(object sender, EventArgs e)
            {
                listView1.View = View.SmallIcon;
               // this.listView1.SmallImageList = this.imageList1;
    
               // this.listView1.BeginUpdate();
    
               
    
               // this.listView1.EndUpdate();
    
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                listView1.View = View.LargeIcon;
                //this.listView1.LargeImageList = this.imageList1;
    
              //  this.listView1.BeginUpdate();
    
                
    
              //  this.listView1.EndUpdate();
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                
                listView1.View = View.Details;
              //  this.listView1.BeginUpdate();   //数据更新,UI暂时挂起,直到EndUpdate绘制控件,可以有效避免闪烁并大大提高加载速度  
    
               
    
                //this.listView1.EndUpdate();  //结束数据处理,UI界面一次性绘制。  
            }
    
            private void listView1_SelectedIndexChanged(object sender, EventArgs e)
            {
                lvTabInfo.Clear();
                lvTabInfo.View = View.Details;
                this.lvTabInfo.Columns.Add("栏目", 100, HorizontalAlignment.Center);//新建的行和列
                this.lvTabInfo.Columns.Add("详细信息", 100, HorizontalAlignment.Center);
                foreach (ListViewItem lvi in listView1.SelectedItems)
                {
                    
                    MessageBox.Show(lvi.Index.ToString());
                    Show(lvTabInfo, "用户状态", lvi.SubItems[0].Text);//显示的信息
                    Show(lvTabInfo, "用户签名", lvi.SubItems[1].Text);
                    Show(lvTabInfo, "电话", lvi.SubItems[2].Text);
                    Show(lvTabInfo, "QQ号码", "kyi");
                }
                    
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
            private void Show(ListView lv, string title, string info)
            {
                ListViewItem lvi = new ListViewItem();
                lvi.Text = title;
                lvi.ImageIndex = 0;
                //lvi.ImageIndex = 0;
                lvi.SubItems.Add(info);
                lv.Items.Add(lvi);
    
            }

    Listview

    http://blog.csdn.net/xiaohan2826/article/details/8603015

     public partial class Form1 : Form
        {
            public Form1()
            {
                //InitializeComponent();
                InitializeComponent();
                this.listView1.Columns.Add("列标题1", 120, HorizontalAlignment.Left);
                this.listView1.Columns.Add("列标题2", 120, HorizontalAlignment.Left);
                this.listView1.Columns.Add("列标题3", 120, HorizontalAlignment.Left);
                for (int i = 0; i < 10; i++)   //添加10行数据 
                {
                    ListViewItem lvi = new ListViewItem();

                    lvi.ImageIndex = i;     //通过与imageList绑定,显示imageList中第i项图标 

                    lvi.Text = "subitem" + i;

                    lvi.SubItems.Add("第2列,第" + i + "行");

                    lvi.SubItems.Add("第3列,第" + i + "行");

                    this.listView1.Items.Add(lvi);

                }
               lvTabInfo.Clear();
             lvTabInfo.View = View.Details;
                this.lvTabInfo.Columns.Add("栏目", 100, HorizontalAlignment.Center);
                this.lvTabInfo.Columns.Add("详细信息", 100, HorizontalAlignment.Center);

            }
          

            private void button1_Click(object sender, EventArgs e)
            {
                listView1.View = View.SmallIcon;
               // this.listView1.SmallImageList = this.imageList1;

               // this.listView1.BeginUpdate();

              

               // this.listView1.EndUpdate();

            }

            private void button2_Click(object sender, EventArgs e)
            {
                listView1.View = View.LargeIcon;
                //this.listView1.LargeImageList = this.imageList1;

              //  this.listView1.BeginUpdate();

               

              //  this.listView1.EndUpdate();
            }

            private void button3_Click(object sender, EventArgs e)
            {
               
                listView1.View = View.Details;
              //  this.listView1.BeginUpdate();   //数据更新,UI暂时挂起,直到EndUpdate绘制控件,可以有效避免闪烁并大大提高加载速度 

              

                //this.listView1.EndUpdate();  //结束数据处理,UI界面一次性绘制。 
            }

            private void listView1_SelectedIndexChanged(object sender, EventArgs e)
            {
                lvTabInfo.Clear();
                lvTabInfo.View = View.Details;
                this.lvTabInfo.Columns.Add("栏目", 100, HorizontalAlignment.Center);
                this.lvTabInfo.Columns.Add("详细信息", 100, HorizontalAlignment.Center);
                foreach (ListViewItem lvi in listView1.SelectedItems)
                {
                   
                    MessageBox.Show(lvi.Index.ToString());
                    Show(lvTabInfo, "用户状态", lvi.SubItems[0].Text);
                    Show(lvTabInfo, "用户签名", lvi.SubItems[1].Text);
                    Show(lvTabInfo, "电话", lvi.SubItems[2].Text);
                    Show(lvTabInfo, "QQ号码", "kyi");
                }
                   
            }

            private void Form1_Load(object sender, EventArgs e)
            {

            }
            private void Show(ListView lv, string title, string info)
            {
                ListViewItem lvi = new ListViewItem();
                lvi.Text = title;
                lvi.ImageIndex = 0;
                //lvi.ImageIndex = 0;
                lvi.SubItems.Add(info);
                lv.Items.Add(lvi);

            }

  • 相关阅读:
    储存过程、游标与触发器
    linux系统安装mysql5.7.22
    为什么实体类要实现序列化
    jsp的语法
    jsp的原理
    转发和重定向的区别
    SpringCloud——简介,5大组件
    Java——线程,并发包(Lock、线程池)
    Spring Data JPA——基本使用
    SpringBoot
  • 原文地址:https://www.cnblogs.com/7-58843117/p/7655441.html
Copyright © 2011-2022 走看看