• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

displaying drop down in a dbgrid control

How do i correctly allign the listbox to show a dropdown in the dbgrid (ButtonClick event)? It is possible to do show it using the Rowheight property but alligning it presicely is a problem. Any suggestions?
1 Solution
You might find it difficult doing this. I suggest using a 3rd party OCX, like True DBGrid from Apex SC.
You have to take in consideration, what if the user has large fonts display settings and small fonts display settings. Use twixperpixel(x,y).
More I can't think of.

I hope this will help you. I didn't post it as an answer since I do not belive it is!

This example uses a list box, but you can replace the name of the list control with a combobox to achieve the same result :

Replace grdCensus with your grid control name.

First in the click command of the list/combo control :

Private Sub DBList1_Click()

grdCensus.Col = 2 'replace with the column you need
grdCensus.Text = DBList1.Text
grdCensus.Col = 3 'the next col you want to have focus
DBList1.Visible = False

End Sub

In the RowColChange event of your grid :

With grdCensus
'in the code below replace 2 with your column #
    If .Col = 2 And .Text = "" Then
       DBList1.Left = .Left + .Columns(2).Left
       DBList1.Top = .Top + (.Row * .RowHeight) + SSTab1.Top
'the line below makes sure the list isn't being shown off
'the bottom of the screen. You'll need to adjust the value
'3600 as needed depending on your forms size and position
       If DBList1.Top > 3600 Then DBList1.Top = 3600
       DBList1.ZOrder 0
       DBList1.Visible = True
       DBList1.Visible = False
    End If
end with


Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now