c# listbox颜色控制问题
来源:百度知道 编辑:UC知道 时间:2024/06/03 15:44:02
还是用listview更方便吧
在form上拖以listview
public Form1()
{
InitializeComponent();
this.listView1.View = View.Details;
this.listView1.HeaderStyle = ColumnHeaderStyle.None;
this.listView1.FullRowSelect = true;
this.listView1.Columns.Add("");
this.listView1.Columns[0].Width = this.listView1.Width-24;
this.listView1.Scrollable = true;
this.listView1.Items.Add(Color.Green.Name);
this.listView1.Items[0].ForeColor = Color.Green;
this.listView1.Items.Add(Color.Blue.Name);
this.listView1.Items[1].ForeColor = Color.Blue;
this.listView1.Items.Add(Color.Red.Name);
this.listView1.Items[2].ForeColor = Color.Red;
}