zoukankan      html  css  js  c++  java
  • listview点击checkbox,修改值

    1.初始化控件


                listView1.Items.Clear();
                listView1.Columns.Clear();
                ColumnHeader ch = new ColumnHeader();
                ch.Width = 100;
                ch.Text = "终端";
                listView1.Columns.Add(ch);

                ColumnHeader ch2 = new ColumnHeader();
                ch2.Width = 100;
                ch2.Text = "开关状态";
                listView1.Columns.Add(ch2);

                listView1.View = View.Details;
                listView1.GridLines = true;
                listView1.FullRowSelect = true;

                string[] strs = txtConCode.Text.Split(',');
                for (int i = 0; i < strs.Length; i++)
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = strs[i];
                    lvi.SubItems.Add("合闸");
                    listView1.Items.Add(lvi);
                }

    2.点击checkbox值,修改对应的值

     private void listView1_ItemChecked(object sender, ItemCheckedEventArgs e)
            {
                for (int i = 0; i < listView1.Items.Count; i++)
                {
                    if (listView1.Items[i].Checked == true)
                    {
                        listView1.Items[i].SubItems[1].Text = "分闸";
                    }
                    else
                    {
                        listView1.Items[i].SubItems[1].Text = "合闸";
                    }
                }
            }

  • 相关阅读:
    Linux 6 修改ssh默认远程端口号
    win7安装镜像注入USB3.0,NVMe驱动
    Spring Cloud(7):Zuul自定义过滤器和接口限流
    Spring Cloud(6):Zuul的基本使用
    Spring Cloud(5):Hystrix的使用
    Spring Cloud(4):Feign的使用
    Spring Cloud(3):Ribbon的使用
    Spring Cloud(2):搭建Eureka
    Spring Cloud(1):微服务简介
    SpringBoot 2.x (15):Actuator监控
  • 原文地址:https://www.cnblogs.com/Anders888/p/4030956.html
Copyright © 2011-2022 走看看