コード例 #1
0
        public void Init()
        {
            List <GroupConfig1> groups = ConfigData.GroupConfigRoot.GroupConfig1s;

            foreach (GroupConfig1 g1 in groups)
            {
                TabPage tabpage = new TabPage(g1.Name);
                tabpage.Tag = g1;
                tabControl1.TabPages.Add(tabpage);
                CustomPASListView paslv = new CustomPASListView(g1);
                paslv.Dock   = DockStyle.Fill;
                paslv.Parent = tabpage;
                foreach (GroupConfig2 g2 in g1.GroupConfigs)
                {
                    ListViewGroup lvg = new ListViewGroup(g2.Name);
                    paslv.Groups.Add(lvg);
                    foreach (GroupConfig3 g3 in g2.GroupConfigs)
                    {
                        foreach (Sensor ss in g3.Sensors)
                        {
                            ListViewItem lvi = new ListViewItem(lvg);
                            lvi.Tag = ss;
                            paslv.Items.Add(lvi);
                            lvi.Group = lvg;
                            lvi.Text  = ss.GroupName;
                            lvi.SubItems.AddRange(new ListViewItem.ListViewSubItem[] {
                                new ListViewItem.ListViewSubItem(lvi, ss.Model.Title),
                                new ListViewItem.ListViewSubItem(lvi, ss.Comment),
                                new ListViewItem.ListViewSubItem(lvi, ss.Uid),
                                new ListViewItem.ListViewSubItem(lvi, ss.NodeId),
                                new ListViewItem.ListViewSubItem(lvi, ss.PortId)
                            });
                        }
                    }
                }
                paslv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                paslv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            }
            TabPage tbAdd = new TabPage(" 十");

            tabControl1.TabPages.Add(tbAdd);
            tbAdd.Name            = "tbAdd";
            tabControl1.Selected += TabControl1_Selected;
        }
コード例 #2
0
 private void TabControl1_Selected(object sender, TabControlEventArgs e)
 {
     if (e.TabPage == tabControl1.TabPages["tbAdd"])
     {
         InputForm inf = new InputForm();
         if (inf.ShowDialog() == DialogResult.OK)
         {
             string name = inf.StrValue;
             if (!string.IsNullOrWhiteSpace(name))
             {
                 tabControl1.TabPages.Insert(tabControl1.TabPages.Count - 1, name, name);
                 GroupConfig1 gc1 = new GroupConfig1();
                 gc1.Name = name;
                 tabControl1.TabPages[name].Tag = gc1;
                 CustomPASListView cp = new CustomPASListView(gc1);
                 cp.Parent = tabControl1.TabPages[name];
                 return;
             }
         }
         tabControl1.SelectedTab = tabControl1.TabPages[0];
     }
 }