Has anyone here tried putting a combobox to a bound datagridview? The selected value of the combobox will depend on the value of the corresponding column in the database.

I have a datagridview. When the user clicks the edit button, the application fetches the records from the database and binds it to the datagriview. But I want to show the Gender Column as a combobox with selectable 'Male' and 'Female' values.

How could I add a combobox to bound datagridview?

Re: adding combobox to bound datagridview 80 80

I have added a combobox to the datagridview BUT it just adds a new column to the datagridview. What i want to happen is the GENDER column from the database be displayed as a combobox.

Dim col As New DataGridViewComboBoxColumn
            col.HeaderText = "Gender"
            col.Name = "Gender"
            col.DataSource = GetData("SELECT * FROM AuxInfo WHERE ID=1", auxinfo, auxinfoDataSource)
            col.DisplayMember = "Value"
            gridDependents.Columns.Add(col)

whew what a bummer I am.:(

Re: adding combobox to bound datagridview 80 80

I'm thinking of adding the records from the dataset into the datagridview programmatically. But is there more efficient approach on doing this?

Please.

Re: adding combobox to bound datagridview 80 80

BUMP

Re: adding combobox to bound datagridview 80 80

Just add a Template Field In Gridview Then Go to Edit Template,In Edit Template Portion Use A Combobox,When U Will Click in Edit Button This Combobox Will Be Display There

Re: adding combobox to bound datagridview 80 80

I'm using a DataGridView.

I have a datagridview. When the user clicks the edit button, the application fetches the records from the database and binds it to the datagriview. But I want to show the Gender Column as a combobox with selectable 'Male' and 'Female' values.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.