toolbar可以添加listview吗
1个回答
展开全部
toolbar可以添加listview
DataTable dtTree = new DataTable();
dtTree.Columns.Add("ID",typeof(string));
dtTree.Columns.Add("Code", typeof(string));
dtTree.Columns.Add("Name", typeof(string));
dtTree.Columns.Add("Description", typeof(string));
dtTree.Columns.Add("ParentID", typeof(string));
//新增加的列 布尔类型才能绑定checkbox
dtTree.Columns.Add("Tag", typeof(bool));
dtTree.Columns.Add("Happy", typeof(string));
DataRow row = dtTree.NewRow();
row["ID"] = "1";
row["Code"] = "001";
row["Name"] = "野原广志";
row["Description"] = "野原广志";
row["ParentID"] = "-1";
row["tag"] = false;
row["Happy"] = "爱吃青椒";
dtTree.Rows.Add(row);
DataRow row2 = dtTree.NewRow();
row2["ID"] = "2";
row2["Code"] = "002";
row2["Name"] = "野原美呀";
row2["Description"] = "野原美呀";
row2["ParentID"] = "-1";
row2["tag"] = false;
row2["Happy"] = "爱吃青椒";
dtTree.Rows.Add(row2);
DataRow row3 = dtTree.NewRow();
row3["ID"] = "3";
row3["Code"] = "003";
row3["Name"] = "野原新之助";
row3["Description"] = "野原新之助";
row3["ParentID"] = "-1";
row3["tag"] = false;
row3["Happy"] = "不爱吃青椒";
dtTree.Rows.Add(row3);
DataRow row4 = dtTree.NewRow();
row4["ID"] = "4";
row4["Code"] = "004";
row4["Name"] = "野原小白";
row4["Description"] = "野原小白";
row4["ParentID"] = "3";
row4["tag"] = false;
row4["Happy"] = "不爱吃青椒";
dtTree.Rows.Add(row4);
//模拟数据 将查询出来的datatable添加一列 例如:tag
//然后查询datatable type列 当type为“板式”,“沙发”时 将tag列置为true
DataRow[] drs = dtTree.Select("Happy='爱吃青椒'");
foreach (DataRow item in drs)
{
item["tag"] = true;
}
treeList1.DataSource = dtTree;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询