3

Is it possible to make every item of a listbox as a combobox? I need this because i made the listbox as checkable and then I need to make the user to choose from different options for every element of the list.

Thanks!

Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250
Francesco Bonizzi
  • 5,142
  • 6
  • 49
  • 88

2 Answers2

5

If you are not planning on distributing your application then you can also look at the TreeView Control. See this example.

CODE

Private Sub CommandButton1_Click()
    With TreeView1.Nodes
        .Add , , "R1", "Root 1"
        .Add "R1", tvwChild, , "Test 1"
        .Add "R1", tvwChild, , "Test 2"
        .Add "R1", tvwChild, , "Test 3"
        .Add "R1", tvwChild, , "Test 4"
        .Add "R1", tvwChild, , "Test 5"

        .Add , , "R2", "Root 2"
        .Add "R2", tvwChild, , "Test 11"
        .Add "R2", tvwChild, , "Test 22"
        .Add "R2", tvwChild, , "Test 33"
        .Add "R2", tvwChild, , "Test 44"
        .Add "R2", tvwChild, , "Test 55"
    End With
End Sub

SNAPSHOT

enter image description here

USING THE CONTROL

To be able to use the Treeview Control, your system must have MSCOMCTL.OCX registered. You can then add the control by Right Clicking on the

SNAPSHOT

enter image description here

DESIGN TIME SNAPSHOT

enter image description here

DOWNLOAD THE OCX

If you do not have the OCX then you can download it from here

Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250
  • 2
    +1 You're answers have always amazed me. You fully describe each and every step that should be followed, and that too with pictures :) – Kartik Anand Jul 01 '12 at 09:46
  • 1
    Thank You Kartik :) That is because the answer is not only aimed at the `Asker` but anyone who comes here looking for a similar query ;) – Siddharth Rout Jul 01 '12 at 09:50
  • The common controls library is not available for 64x installations (http://office.microsoft.com/en-us/word-help/choose-the-32-bit-or-64-bit-version-of-microsoft-office-HA010369476.aspx#_Toc254341418) – Fionnuala Jul 01 '12 at 10:41
  • @remou: It is not available for office 64 bit but is available for office 32 bit on 64 bit windows – Siddharth Rout Jul 01 '12 at 10:54
3

You could achieve such an effect by replacing you listbox by a subform in datasheet view.
You will have the mimic the multiselect by providing a checkbox, and you could have a second column as a listbox.

iDevlop
  • 24,841
  • 11
  • 90
  • 149
  • Seems like the sensible solution to me. I general prefer continuous forms to datasheets, because it gives a better level of control, but *chacun à son goût* :) – Fionnuala Jul 01 '12 at 09:21
  • @Remou: Having a form in Datasheet view gives you mostly the same level of control as the form in Form view: events, combo...just a bit less cosmetic choice. Or am I missing something ? – iDevlop Jul 01 '12 at 21:24
  • Headers and footers, for one, are a lot more than cosmetic. Also, at what point does layout switch from cosmetic to an important part of data entry? Which is the last control on a datasheet? – Fionnuala Jul 01 '12 at 21:43