add a combo box in a specific row in datagrid view c#

  • Thread starter Thread starter mrwhat
  • Start date Start date
M

mrwhat

Guest
I want to have a combobox in a specific cell in my data grid view. can somebody help? For the table im using data table

Problem: i want to put a combobox in a specific cell like in column 1 and row 1.

Here is how I populate the table--

public DataTable createGridForForm(int rows, int columns)
{
// Create the output table.
DataTable table = new DataTable();

for (int i = 1; i <= columns; i++)
{
table.Columns.Add("column " + i.ToString());
}

for (int i = 1; i < rows; i++)
{
DataRow dr = table.NewRow();
// populate data row with values here
ListBox test = new ListBox();
myTabPage.Controls.Add(test);
table.Rows.Add(dr);
}
return table;
}

And here is how I create the datagridview.

private void createGridInForm(int rows, int columns)
{
DataGridView RunTimeCreatedDataGridView = new DataGridView();
RunTimeCreatedDataGridView.DataSource = createGridForForm(rows, columns);

//DataGridViewColumn ID_Column = RunTimeCreatedDataGridView.Columns[0];
//ID_Column.Width = 200;

int positionForTable = getLocationForTable();
RunTimeCreatedDataGridView.BackgroundColor = Color.WhiteSmoke;

RunTimeCreatedDataGridView.Size = new Size(995, 200);
RunTimeCreatedDataGridView.Location = new Point(5, positionForTable);
myTabPage.Controls.Add(RunTimeCreatedDataGridView);
}

Continue reading...
 
Back
Top