其他分享
首页 > 其他分享> > 自定义listview向其中动态增加控件

自定义listview向其中动态增加控件

作者:互联网

 1    private void InitARListView()
 2         {      
 3             int count = arListView1.Items.Count;
 4             arListView1.Items.Clear();
 5             //for (int i = arListView1.Items.Count - 1; i >= 0; i--)
 6             //{
 7             //    arListView1.Items.RemoveAt(i);
 8             //}
 9             ImageList imglist = new ImageList();
10             imglist.ImageSize = new Size(5, 30);
11             arListView1.SmallImageList = imglist;
12             //for (int i = 0; i < DeviceObject.process_model.Count; i++)
13             //{
14             //    AddNewARListViewItem(DeviceObject.process_model[i]);
15             //}
16             ListViewItem[] listViewItems = new ListViewItem[DeviceObject.process_model.Count];
17             for (int i = 0; i < DeviceObject.process_model.Count; i++)
18             {
19                 //ListViewItem lvitem1 = arListView1.Items.Add($"{i}");
20                 //ListViewItem lvitem = new ListViewItem();
21                 //lvitem.Checked= DeviceObject.process_model[i].isTest;
22                 //lvitem.SubItems.Add($"{i}");
23 
24                 
25                 ListViewItem lvitem = new ListViewItem($"{i}");
26                 lvitem.Checked = DeviceObject.process_model[i].isTest;
27                 lvitem.Name = i.ToString();
28                 int sumnum = arListView1.Items.Count;
29                 arListView1.Items.Add(lvitem);
30                 // lvitem.Checked = DeviceObject.process_model[i].isTest;
31 
32                 ARListView.EXComboBoxListViewSubItem combox = new ARListView.EXComboBoxListViewSubItem();
33                 lvitem.SubItems.Add(combox);
34                 //设置ComboBox组件
35                 this.arListView1.AddComboBoxToSubItem(1, i, combox, DockStyle.Fill);
36                 BoundsComboBox(combox.Combox, DeviceObject.process_name, "");
37                 combox.Combox.SelectedValue = DeviceObject.process_model[i].testName == null ? "测试名称" : DeviceObject.process_model[i].testName;
38                 combox.Combox.SelectedValueChanged += new EventHandler(Combox_SelectedValueChanged);
39                 combox.Combox.Font = new Font(combox.Combox.Font.FontFamily, 10, FontStyle.Regular);
40                 combox.Combox.FlatStyle = FlatStyle.Flat;
41                 combox.Combox.DropDownStyle = ComboBoxStyle.DropDownList;
42 
43 
44                 ARListView.EXTextBoxListViewSubItem txtbox = new ARListView.EXTextBoxListViewSubItem();
45                 //设置TextBox组件
46                 this.arListView1.AddTextBoxToSubItem(2, i, txtbox, DockStyle.Fill);
47                 txtbox.TxtBox.Text = DeviceObject.process_model[i].testExplain == null ? "测试说明" : DeviceObject.process_model[i].testExplain;
48                 txtbox.TxtBox.TextChanged += new EventHandler(TxtBox_TextChanged);
49                 txtbox.TxtBox.Font = new Font(txtbox.TxtBox.Font.FontFamily, 10, FontStyle.Regular);
50                 txtbox.TxtBox.BorderStyle = BorderStyle.FixedSingle;
51                 lvitem.SubItems.Add(txtbox);
52 
53 
54                 ARListView.EXButtonListViewSubItem btn = new ARListView.EXButtonListViewSubItem();
55                 //设置Button组件
56                 this.arListView1.AddButtonToSubItem(3, i, btn, DockStyle.Fill);
57                 btn.Btn.Text = "设置";
58                 btn.Text = "设置";
59                 btn.Btn.Click += new EventHandler(OpenAlgorithmSetForm);
60                 btn.Btn.Font = new Font(btn.Btn.Font.FontFamily, 10, FontStyle.Regular);
61                 btn.Btn.FlatStyle = FlatStyle.Flat;
62                 lvitem.SubItems.Add(btn);
63 
64                 lvitem.Remove();
65                 
66                 arListView1.Items.Insert(i, lvitem);
67                 //arListView1.Items.Add(lvitem);
68                
69             }
70 
71         }
View Code

 

标签:控件,arListView1,自定义,DeviceObject,process,lvitem,new,model,listview
来源: https://www.cnblogs.com/1228941830ying/p/16580666.html