User Control - DataGridView with combobox columns - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

User Control - DataGridView with combobox columns

esb1922esb1922 Posts: 14Member
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";


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 (combo list is built ok)

Any idea?
Sign In or Register to comment.