using Jues.CustomListItemView;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using static System.Windows.Forms.ListViewItem;
namespace Demo
{
public partial class Form1 : Form
{
private CustomControl customControl;
public Form1()
{
InitializeComponent();
customControl = new CustomControl(this.listView1);
toolStripButtonAdd_Click(null, null);
}
private void toolStripButtonAdd_Click(object sender, EventArgs e)
{
ListViewItem listViewItem = new ListViewItem();
// name
listViewItem.Text = String.Format("jues {0}",this.listView1.Items.Count+1);
this.listView1.Items.Add(listViewItem);
// TextBox
TextBox textBox = new TextBox();
textBox.Text = String.Format("textBox {0}", this.listView1.Items.Count + 1);
customControl.Insert( this.columnHeaderTextBox.Index, listViewItem, textBox);
// ComboBox
ComboBox comboBox = new ComboBox();
comboBox.Items.Add("Baby");
comboBox.Items.Add("Young");
comboBox.Items.Add("Old");
customControl.Add(listViewItem, comboBox);
comboBox.SelectedIndex = this.listView1.Items.Count % comboBox.Items.Count;
// progressBar
ProgressBar progressBar = new ProgressBar();
progressBar.Maximum = 10;
progressBar.Value = this.listView1.Items.Count % progressBar.Maximum;
customControl.Add(listViewItem, progressBar);
// Button
Button button = new Button();
button.Text = "Delete";
ListViewSubItem buttonSubItem = customControl.Add(listViewItem, button);
button.Click += delegate (object sender1, EventArgs e1)
{
customControl.Remove(listViewItem);
// this.listView1.Items.Remove(listViewItem);
};
}
}
}
nupkg包:
标签:控件,listView1,C#,Items,进度条,customControl,Add,comboBox,listViewItem From: https://www.cnblogs.com/guangzhiruijie/p/17849631.html