我想通过 for 循环将 textBox 添加到我的列单元格...
我的代码:
DataTable dt = new DataTable();
DataColumn dc;
dc = new DataColumn("No");
dt.Columns.Add(dc);
dc = new DataColumn("Item");
dt.Columns.Add(dc);
dc = new DataColumn("Available Stock");
dt.Columns.Add(dc);
dc = new DataColumn("Quantity");
dt.Columns.Add(dc);
dc = new DataColumn("Price");
dt.Columns.Add(dc);
// Define rows
for (int i = 0; i < count; i++)
{
string no = dtr.Rows[i][0].ToString();
string item = dtr.Rows[i][2].ToString() + " " + dtr.Rows[i][1].ToString();
string A_qty = dtr.Rows[i][3].ToString();
string price = dtr.Rows[i][4].ToString();
dt.Rows.Add(no, item, A_qty,"[i want to add text box here] " ,price);
}
dataGridView1.DataSource = dt;
我想将文本框添加到第 4 列,并且我想一一访问。