datagrid combobox problem

M

Martin Williams

I have inserted a combobox into a datagrid cell. I am having difficulty
getting the cell to retain the combobox selection. When I leave the cell,
it remains empty.

Here is the code, based on the Microsoft Article Q323167:

public mycombo as new combobox

FORM1_LOAD
mycombo.datasource = datset.tables("Inventory")
mycombo.displaymember = "Title"
mycombo.visible = false

SUB DATAGRID1_PAINT
if datagrid1.currentcell.columnnumber = 2 or _
datagrid1.currentcell.columnnumber = 3 then
mycombo.width = datagrid1.getcurrentcellbounds.width
end if

SUB CTRLS_TEXTCHANGED
if datagrid1.currentcell.columnnumber = 2 or _
datagrid1.currentcell.columnnumber = 3 then
datagrid1.item(datagrid1.currentcell) = mycombo.text
end if

SUB DATAGRID1_CURRENTCELLCHANGED
if datagrid.currentcell.columnnumber = 2 then
mycombo.visible = false
mycombo.width = 0
mycombo.left = datagrid1.getcurrentcellbounds.left
mycombo.top = datagrid1.getcurrentcellbounds.top
mycombo.text = datagrid1.item(datagrid1.currentcell) & ""
mycombo.visible = true
else
mycombo.visible = false
mycombo.width = 0
end if

SUB DATAGRID1_SCROLL
mycombo.visible = false
mycombo.width = 0

SUB DATAGRID1_CLICK
mycombo.visible = false
mycombo.width = 0

Thanks for all responses.

Regards,
Martin Williams
 
M

Martin Williams

Is that the only way to get it to work? I really wanted a bound combobox
within the datagrid.

Regards,
Martin Williams
 
K

Ken Tucker [MVP]

Hi,

Yes.

Ken
-------------------
Martin Williams said:
Is that the only way to get it to work? I really wanted a bound combobox
within the datagrid.

Regards,
Martin Williams
 
M

Martin Williams

Well, after much experimenting, I got it to work. The following needs to be
added to FORM1_LOAD:

AddHandler MyCombo.SelectionChangeCommitted, AddressOf Ctrls_Textchanged
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top