Example #1
0
        private void AddSection(ref ScrollPanel bsp, SectionParam para, List <ConfigParam2> lstVars)
        {
            if (bsp == null || para == null || lstVars == null)
            {
                return;
            }

            GroupListView2 glv2 = new GroupListView2();
            ConfigListView clv  = glv2.EmbeddLV;

            clv.Scrollable = false;

            // Add  columns
            ColumnHeader columnHeader1 = new ColumnHeader();

            columnHeader1.Width     = FirstColumnWidth;
            columnHeader1.TextAlign = HorizontalAlignment.Left;
            columnHeader1.Text      = "Name";

            ColumnHeader columnHeader2 = new ColumnHeader();

            columnHeader2.Width     = SecondColumnWidth;
            columnHeader2.TextAlign = HorizontalAlignment.Left;
            columnHeader2.Text      = "Description";

            clv.Name = para.SectionName;
            clv.Columns.AddRange(new ColumnHeader[] { columnHeader1, columnHeader2 });

            glv2.LabelText = para.SectionName;

            Node   node = para.getNode();
            string configDesc, configValue;
            int    nColumn1Width;

            while (node != null)
            {
                configDesc  = ((TypeList <string>)node).getDesc();
                configValue = ((TypeList <string>)node).getData();

                AddItem(ref clv, lstVars, para.SectionName, configDesc, configValue);

                nColumn1Width    = DetermineWidth(configDesc);
                FirstColumnWidth = nColumn1Width > FirstColumnWidth ? nColumn1Width : FirstColumnWidth;
                node             = node.getNext();
            }

            // Add custom draw
            clv.OwnerDraw = true;
            clv.DrawItem += new DrawListViewItemEventHandler(clv_DrawItem);

            if (clv.RowHeight > LVSmallChange)
            {
                LVSmallChange = clv.RowHeight;
            }

            if (glv2.Height > LVLargeChange)
            {
                LVLargeChange = glv2.Height;
            }

            glv2.SetPreferedHeight();

            bsp.Controls.Add(glv2);
        }