How to use the Drop down / combobox control from a DataGrid cell on button click?

I have a DataGrid that I've bound to an ADODC control, which is bound to a table in an Access database.

I need to edit one of those columns like a combo box, e.g. drop down a list when the cell button is clicked and select the value.

I've managed to build the DataGrid, bind it properly and set the cells in this column to have a button which, according to the documentation by Microsoft, can drop down a built-in combobox. I can't find any built-in dropdown controls, and most examples out there are no longer available, can someone help me?

Update 1

I managed to hack a ComboBox inside the GridView, but still help polishing the details. I made an invisible combobox and when you click a cell it teleports to the datagrid cell, redimensions itself to fit the cell, loads itself with the data from that column and becomes visible. My problem now is that in order to make that combo box appear I have to click 3 times:

  1. Focus the cell to make the button appear.
  2. Click the button to make the combo box appear.
  3. Click the combo box to drop it down, displaying the options.

Ideally I should be able to display the list the first time the cell is clicked, but given the barriers I can also use 2 clicks.

Upvotes: 1

Views: 431

Answers (1)

BobRodes
BobRodes

Reputation: 6165

I'm afraid the "built-in dropdown" is "vaporware," i.e. software features that are documented but don't really exist. What you have done is the right way to do the job.

To avoid extra mouse clicks, you might want to use the KeyUp event to map a key to your DataGrid's ButtonClick event, for example the Enter key. You'll have to tinker with SetFocus to get it to focus properly, but if you go to the trouble you'll find that you can use the control with a lot less effort.

Upvotes: 2

Related Questions