osthus
asked on
DataGrid control 6.0, Buttonclick
The datagrid control has a buttonclick event. This event is fantastic if you want a combo box to appear. But how?
If you set a button then dbGrid_buttonclick becomes an option. Use this to pop up a list of choices, for example. To tell you the truth, it's essentially an add for dbgrid pro, which actually has built in functionality.
heh,
'how' was the question I believe... oops. I hate dbgstandard, it is just good enough to make you want dbgpro.
Create your grid, assign your button in properties / layout.
Also create a dbcombo with .visible=false. Then double click the grid, and select the 'buttonclick' procedure which has appeared. Enter code there, something like..
dbcombo.top=currentcell.to p
dbcombo.left=currentcell.l eft
dbcombo.visible=true
That's it!! This is something I thought I would use at some point like yourself, but really unless you buy dbgPro there are too many other, better user interfaces.
'how' was the question I believe... oops. I hate dbgstandard, it is just good enough to make you want dbgpro.
Create your grid, assign your button in properties / layout.
Also create a dbcombo with .visible=false. Then double click the grid, and select the 'buttonclick' procedure which has appeared. Enter code there, something like..
dbcombo.top=currentcell.to
dbcombo.left=currentcell.l
dbcombo.visible=true
That's it!! This is something I thought I would use at some point like yourself, but really unless you buy dbgPro there are too many other, better user interfaces.
At form's activate event, set Button property to true for the columns you want combo box like the one below as an example:
grdDataGrid.Columns(2).But ton = True
grdDataGrid.Columns(3).But ton = True
On the grid BeforeColEdit event, put the following code:
If grdDataGrid.Columns(ColInd ex).DataFi eld = "TransactionType" Or grdDataGrid.Columns(ColInd ex).DataFi eld = "Bank" Then
' Let the user edit by entering a key.
If KeyAscii <> 0 Then Exit Sub
' Otherwise, cancel built-in editing and call the
' ButtonClick event to drop down List1.
Cancel = True
grdDataGrid_ButtonClick (ColIndex)
End If
For my example grdDataGrid.Columns(2) bound to datafield "TransactionType" and grdDataGrid.Columns(3) bound to datafield "Bank". If user click on the button on these 2 fields, ButtonClick event will be called to display the list for user to select a value.
grdDataGrid.Columns(2).But
grdDataGrid.Columns(3).But
On the grid BeforeColEdit event, put the following code:
If grdDataGrid.Columns(ColInd
' Let the user edit by entering a key.
If KeyAscii <> 0 Then Exit Sub
' Otherwise, cancel built-in editing and call the
' ButtonClick event to drop down List1.
Cancel = True
grdDataGrid_ButtonClick (ColIndex)
End If
For my example grdDataGrid.Columns(2) bound to datafield "TransactionType" and grdDataGrid.Columns(3) bound to datafield "Bank". If user click on the button on these 2 fields, ButtonClick event will be called to display the list for user to select a value.
ASKER
The question was how to show the combo box when the buttonclick event is fired
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
My answer shows a combo box. There is no actual function/box built into the button, it's just there so you can access the buttonclick procedure.