C# 调用项并将其添加到datagridview中的新组合框中
在我的程序中,在datagrid视图的前两行中有一些带有可变编号(取决于用户选择)的组合框。现在我想添加项并在其他类中使用它们,但我没有访问它们的权限,因为在创建之前我不知道如何调用它们?(它们是在运行时创建的) //我就是这样创建它们的:C# 调用项并将其添加到datagridview中的新组合框中,c#,datagridview,combobox,datagridviewcomboboxcell,C#,Datagridview,Combobox,Datagridviewcomboboxcell,在我的程序中,在datagrid视图的前两行中有一些带有可变编号(取决于用户选择)的组合框。现在我想添加项并在其他类中使用它们,但我没有访问它们的权限,因为在创建之前我不知道如何调用它们?(它们是在运行时创建的) //我就是这样创建它们的: for (int j = 0; j < columncount; j++) { dataGridView1.Rows[i].Cells[j] = new DataGridViewComboBoxCell(); } for(int j=0;j
for (int j = 0; j < columncount; j++) {
dataGridView1.Rows[i].Cells[j] = new DataGridViewComboBoxCell();
}
for(int j=0;j
行代码的演示怎么样
public Form0114()
{
InitializeComponent();
Combox();
}
public void Combox()
{
dataGridView1.ColumnCount = 3;
dataGridView1.Columns[0].Name = "Product ID";
dataGridView1.Columns[1].Name = "Product Name";
dataGridView1.Columns[2].Name = "Product Price";
string[] row = new string[] { "1", "Product 1", "1000" };
dataGridView1.Rows.Add(row);
row = new string[] { "2", "Product 2", "2000" };
dataGridView1.Rows.Add(row);
row = new string[] { "3", "Product 3", "3000" };
dataGridView1.Rows.Add(row);
row = new string[] { "4", "Product 4", "4000" };
dataGridView1.Rows.Add(row);
DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
cmb.HeaderText = "Select Data";
cmb.Name = "cmb";
cmb.MaxDropDownItems = 4;
cmb.Items.Add("True");
cmb.Items.Add("False");
dataGridView1.Columns.Add(cmb);
}
行代码的演示怎么样
public Form0114()
{
InitializeComponent();
Combox();
}
public void Combox()
{
dataGridView1.ColumnCount = 3;
dataGridView1.Columns[0].Name = "Product ID";
dataGridView1.Columns[1].Name = "Product Name";
dataGridView1.Columns[2].Name = "Product Price";
string[] row = new string[] { "1", "Product 1", "1000" };
dataGridView1.Rows.Add(row);
row = new string[] { "2", "Product 2", "2000" };
dataGridView1.Rows.Add(row);
row = new string[] { "3", "Product 3", "3000" };
dataGridView1.Rows.Add(row);
row = new string[] { "4", "Product 4", "4000" };
dataGridView1.Rows.Add(row);
DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
cmb.HeaderText = "Select Data";
cmb.Name = "cmb";
cmb.MaxDropDownItems = 4;
cmb.Items.Add("True");
cmb.Items.Add("False");
dataGridView1.Columns.Add(cmb);
}