PDA

Click to See Complete Forum and Search --> : come on guys, don't let me down


netSurfer
Jan 26th, 2000, 01:41 AM
Can't anyone help me?

How do I use the DBGrid's button property? The help that I have just says:
Typically, you enable the column button when you want to drop down a control (such as the built-in combo box, a bound list box, or even another DBGrid control) for editing or data entry. When the button in the current cell is clicked, the ButtonClick event will be fired. You can then write code to drop down the desired control from the cell.

It doesn't give me an example or anything else on how to do this. Can someone help with this?

Aaron Young
Jan 26th, 2000, 02:05 AM
Add an Invisible Listbox to the Form with some List Items in it and set the Appearance to Flat..

Private Sub DBGrid1_ButtonClick(ByVal ColIndex As Integer)
With DBGrid1.Columns(ColIndex)
List1.Move DBGrid1.Left + .Left + 20, DBGrid1.Top + .Top + ((DBGrid1.Row + 1) * DBGrid1.RowHeight) + 230, .Width
List1.Visible = True
List1.SetFocus
End With
End Sub

Private Sub List1_Click()
DBGrid1.Text = List1
List1.Visible = False
End Sub

Private Sub List1_LostFocus()
List1.Visible = False
End Sub


------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com

netSurfer
Jan 26th, 2000, 02:20 AM
Thanks Aaron. That did the trick. It works the same way to use combo boxes? What would be the best way to use a check box? The same way?

Aaron Young
Jan 26th, 2000, 02:27 AM
Sure, you just have to position the Control over the Selected Cell and make sure any selection is transferred back to the cell value.

------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com

netSurfer
Jan 26th, 2000, 02:30 AM
Cool. Thanks again