private void SetColumnWidths() { ScrollPanel glc = this.configScrollPanel; int nControlCount = glc.Controls.Count; for (int g = 0; g < glc.Controls.Count; g++) { GroupListView2 glv = (GroupListView2)glc.Controls[g]; if (glv == null) { continue; } ConfigListView listview = glv.EmbeddLV; if (listview == null) { continue; } if (1 < listview.Columns.Count) { int nWidth = listview.Width; listview.Columns[0].Width = FirstColumnWidth; listview.Columns[1].Width = nWidth - FirstColumnWidth; } } }
private void AddEmbeddedControl() { ScrollPanel glc = this.configScrollPanel; int nControlCount = glc.Controls.Count; for (int g = 0; g < glc.Controls.Count; g++) { GroupListView2 glv = (GroupListView2)glc.Controls[g]; if (glv == null) { continue; } ConfigListView listview = glv.EmbeddLV; if (listview == null) { continue; } string temp; for (int i = 0; i < listview.Items.Count; i++) { // Add edit box TextBox tb = new TextBox(); tb.Size = new Size(SecondColumnWidth, 40); tb.Font = new System.Drawing.Font("Arial Narrow", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); tb.BorderStyle = BorderStyle.FixedSingle; tb.TextAlign = HorizontalAlignment.Left; tb.AutoSize = false; tb.Anchor = ((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left); tb.BackColor = TextBoxBackColor; tb.Click += new System.EventHandler(this.tb_Click); tb.TextChanged += new System.EventHandler(this.tb_TextChanged); ListViewItem lvItemTemp = listview.Items[i]; temp = lvItemTemp.Text; tb.Text = listview.Items[i].SubItems[TextBoxColumn].Text; tb.Tag = listview.Items[i].SubItems[TextBoxColumn].Tag; // text box ConfigParam2 para2 = listview.Items[i].SubItems[TextBoxColumn].Tag as ConfigParam2; para2.Obj = tb; // Put it in the second column of every row listview.AddEmbeddedControl(tb, TextBoxColumn, lvItemTemp.Index); tb.Dispose(); } } }
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); }