在C#中,可以使用以下幾種方法來綁定數據到ListView控件:
List<string> dataList = new List<string>();
dataList.Add("Item 1");
dataList.Add("Item 2");
dataList.Add("Item 3");
listView1.Items.AddRange(dataList.Select(item => new ListViewItem(item)).ToArray());
DataTable dataTable = new DataTable();
dataTable.Columns.Add("Column1");
DataRow row = dataTable.NewRow();
row["Column1"] = "Item 1";
dataTable.Rows.Add(row);
row = dataTable.NewRow();
row["Column1"] = "Item 2";
dataTable.Rows.Add(row);
listView1.View = View.Details;
listView1.Columns.Add("Column1");
listView1.DataSource = dataTable;
BindingList<string> bindingList = new BindingList<string>();
bindingList.Add("Item 1");
bindingList.Add("Item 2");
bindingList.Add("Item 3");
listView1.Items.AddRange(bindingList.Select(item => new ListViewItem(item)).ToArray());
這些是ListView數據綁定的常用方法,根據具體需求選擇適合的方法來綁定數據到ListView控件。