Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[blue]Option Explicit
Public mySubitem As ListSubItem
Private Sub Form_Load()
Dim itmX As ListItem
[COLOR=green]' Set up a l of items with subitems[/color]
Set itmX = ListView1.ListItems.Add(, , "hello")
itmX.ListSubItems.Add , , "just"
itmX.ListSubItems.Add , , "testing"
Set itmX = ListView1.ListItems.Add(, , "goodbye")
itmX.ListSubItems.Add , , "more"
itmX.ListSubItems.Add , , "stuff"
[COLOR=green] ' Now set up combobox - make sure it uses same font as listview to try and ensure similar heights,
' as neither the listview's item height, nor the combobox height can be directly set; they are reliant on the currently selected font[/color]
Set Combo1.Font = ListView1.Font
Combo1.AddItem "tell"
Combo1.AddItem "me"
Combo1.Visible = False
End Sub
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim lp As Long
Dim myitem As ListItem
lp = 1
Do Until x > ListView1.ColumnHeaders(lp).Left And x < ListView1.ColumnHeaders(lp).Left + ListView1.ColumnHeaders(lp).Width
lp = lp + 1
Loop
Set myitem = ListView1.HitTest(30, y)
If Not myitem Is Nothing And lp > 1 Then
Form1.Combo1.Move ListView1.Left + ListView1.ColumnHeaders(lp).Left + 15, ListView1.Top + myitem.Top '
Form1.Combo1.Width = ListView1.ColumnHeaders(lp).Width
Set mySubitem = myitem.ListSubItems(lp - 1)
Combo1.Visible = True
End If
End Sub[/blue]
Form1.Combo1.Move ListView1.Left + ListView1.ColumnHeaders(lp).Left + 15, ListView1.Top + myitem.Top '
Form1.Combo1.Width = ListView1.ColumnHeaders(lp).Width