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?

Recommended Answers

All 5 Replies

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.:(

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

Please.

BUMP

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

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.