0
Answer

User Control - DataGridView with combobox columns

Elmar

Elmar

11y
1.8k
1

Trying to build a simple User Control to populate dataGridView with a Table data. Scenario - Table1: RegionID, Region, ManagerID; Table2: PersonID, Name. I'd like to display Region and Name in the grid where the 2nd column is a combobox with all names from Table 2 and also each cell in the col 2 has value based on ManagerID = PersonID. The code is working fine when it's a win app without user control.
dGrRegions.DataSource = ds.Tables[0]; (ds Dataset SELECT RegionID, Region, ManagerID FROM Table1)
dGrRegions.Columns[0].Visible = false;
dGrRegions.Columns[2].Visible = false;
var column = new DataGridViewComboBoxColumn();
column.DataPropertyName = "PersonID";
column.DataSource = dsPeople.Tables[0]; (Dataset SELECT PersonID, Name...)
column.ValueMember = "PersonID";
column.DisplayMember = "Name";
column.HeaderText = "Manager";
dGrRegions.Columns.Add(column);
but when I create a control and pass all needed info as parameters all works fine except that the col 2 doesn't show current values - it's blank but combobox has all dropdown values
Any idea?