Load DataGridViewComboBox unbound at Runtime

0
0

Hi.

 

I´m using a dataGridView in unbound way. I need to9 load a ComboBox Cell depending of the value of a column in the grid (for each row).

How do I manualiy do it ?

Or how can I load the DataComboCell that´s alread exist in DataGrid ?

 

Code ————————————————————————————

 

BO.boCompanyHouses b = new boCompanyHouses();

b.SelectedHouses(CompanyId);

if(b.Count > 0)
{
int i = 0;
dg1.Columns[2].
foreach (boCompanyHouses s in b.GetEnumerable())
{

dg1.Rows.Add();
dg1.Rows[i].Cells[0].Value = s.CompanyHousesSelected;

dg1.Rows[i].Cells[1].Value = s.HouseShort;
dg1.Rows[i].Cells[1].ReadOnly = true;

—->> Here I need to select the combobox item based on the value of a field in b.Collection…

i++;
}

}

 

Regards,

 

Marcelo

  • You must to post comments
0
0

Frank,

Great. That´s it. Solved.

DataGridViewComboBoxCell ComboCellMain = dg1.Rows[i].Cells[2] as DataGridViewComboBoxCell;
ComboCellMain.DataSource = t;
ComboCellMain.ValueMember = “CurrencyId”;
ComboCellMain.DisplayMember = “CurrencyCode”;
ComboCellMain.DropDownStyle = ComboBoxStyle.DropDownList;

 

Best Regards..

Marcelo Blank

  • You must to post comments
0
0

Hi Marcelo,

not sure if I understood correctly, but if you want to populate the Combobox in each row with different values you can do it like this:

DataGridViewComboBoxCell ComboCell = dg1.Rows[i].Cells[2] as DataGridViewComboBoxCell;
ComboCell.Items.Add (“…”);
ComboCell.Items.Add (“…”);

Hope that helps.

Best regards
Frank

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.