我想知道
如何通过
DataTable
绑定按钮列并将其绑定DataTable
到Datagridview
?
我在这里使用Checkbox
选择我想要使用Button替换它的行。有没有可能的方法?
Datatabe
初始化: -
orderTable = new DataTable();
orderTable.Rows.Clear();
orderTable.Clear();
orderTable.Columns.Add("Select", typeof(bool));
orderTable.Columns.Add("Time");
orderTable.Columns.Add("Date");
orderTable.Columns.Add("Order#");
orderTable.Columns.Add("CustName");
orderTable.Columns.Add("Product");
orderTable.Columns.Add("Imagepath");
orderTable.Columns.Add("datetime");
绑定行: -
DataRow Drorder = orderTable.NewRow();
Drorder["Select"] = false;
Drorder["Time"] = time;
Drorder["Date"] = date;
Drorder["Order#"] = ordernumber;
Drorder["CustName"] = Name;
Drorder["Product"] = prodcutname;
Drorder["Imagepath"] = pathf;
Drorder["datetime"] = folderDatetime;
orderTable.Rows.Add(Drorder);
Orders.DataSource = orderTable;
以下方法给出错误..
指定的演员无效
DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
dataGridView1.Columns.Add(btn);
btn.HeaderText = "Test Button";
btn.Text = "Test Btn";
btn.Name = "btn";
btn.UseColumnTextForButtonValue = true;`