Scenario: You need to dynamically add a drop down list in a DataGridView control in a WinForm. Requirements: The items of the drop down list are dynamically bound with data from database. Solution: 1. Connect to database and retrieve data into a datatable, i.e. dtRanks; 2. Create a DataGridViewCombBoxColumn, set necessary properties of the CombBox column, then add it to the GridView control: DataGridViewComboBoxColumn ranks = new DataGridViewComboBoxColumn(); ranks.DataPropertyName = “TestID”; ranks.Name = “TestID”; ranks.HeaderText […]
Daily Archives: April 28, 2008
1 post