Link to home
Start Free TrialLog in
Avatar of AlHal2
AlHal2Flag for United Kingdom of Great Britain and Northern Ireland

asked on

change type of the selected cell on datagridview when cell is clicked.

I am populating a datagridview with two text columns from the output of a sql stored procedure. I want the user to be able to click on any cell in the grid and see a drop down list of values populated from another database table, one per each column, which they can select from to override the cell content from the initial datasource. i.e I want to change the type of the selected cell from datagridviewtextboxcolumn to datagridviewcomboboxcolumn when the cell is clicked.  Is there any way of doing this?

Avatar of AlHal2
AlHal2
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

What about setting each cell in the grid to a combobox.
The text property of the combobox are the contents of the data table.
At the moment each cell of the grid is like a textbox and is populated by the contents of the data table.
Yuu cannot change type of a datagridview cell, this is not possible. You would need to add comboboxcolumn (have it visible = false, copy data from textboxcell to new comboboxcell, remove textboxcell, and make comboboxcolumn visible.
Avatar of AlHal2

ASKER

Do you have any sample code for this?
ASKER CERTIFIED SOLUTION
Avatar of Priest04
Priest04
Flag of Serbia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AlHal2

ASKER

Thanks