multicolumn list box

Discussion in 'AutoCAD' started by MP, Aug 17, 2004.

  1. MP

    MP Guest

    I'm trying to figure out how to use multicolumns in a list box
    I've been reading help files and trying many variations on the examples but
    just cant get it.

    from the help files i copied their example and it works
    when adding all entries on form_initialize

    (excerpted from :
    ListBox Control, BoundColumn Property Example)


    Private Sub UserForm_Initialize()
    ListBox1.ColumnCount = 2

    ListBox1.AddItem "Item 1, Column 1"
    ListBox1.List(0, 1) = "Item 1, Column 2"
    '...snip...etc
    End sub

    but i wanted a form with two command buttons
    "add to column 1", and "add to column 2"

    so I tried to copy paste from the initialization code above
    Private Sub cmdAddCol_1_Click()
    ListBox1.AddItem "Item 1, Column 1"
    End Sub

    Private Sub cmdAddCol_2_Click()
    ListBox1.List(0, 1) = "Item 1, Column 2"
    End Sub

    a minute ago it was giving some error (don't remember the exact wording -
    something about bad array index or ???)
    now, i don't know what I changed but now it's not erroring,
    but cmdAddCol_2_Click appears to do nothing,
    the entry is not added to column 2
    cmdAddCol_1_Click does appear to work correctly.

    I also tried(based on some other help example)
    Private Sub cmdAddCol_2_Click()
    ListBox1.BoundColumn = 1
    ListBox1.List(0, 1) = "Item 1, Column 2"
    End Sub
    and when that didn't work (it adds to column 1)
    then i thought maybe the index is 1 based so i tried
    Private Sub cmdAddCol_2_Click()
    ListBox1.BoundColumn = 2
    ListBox1.List(0, 1) = "Item 1, Column 2"
    End Sub
    that also did not work(still adds to column1)


    maybe a listbox isn't what I should be using.
    I wanted to see two columns
    each column could be added to or removed from independently
    but they would be "linked" in the sense that the entry in row 1 column 1
    will be later programatically combined with row 1 column 2

    so I'm trying to figure out how to do something like the following:

    - invalid pseudocode
    'populate lists
    ListBox1.Row(0).Column(0).Add item "Row 1 Column 1"
    ListBox1.Row(0).Column(1).Add item "Row 1 Column 2"

    and later
    'read lists back
    msgbox "Row 1 column 1: " & listBox1.Row(0).Column(0).Value
    msgbox "Row 1 column 2: " & listBox1.Row(0).Column(1).Value

    kind of like if you had a listbox showing association codes like in an
    entity list in lisp
    (0 . "Type")
    (2 . "Name")
    etc

    there is also a ColumnHeader property I can set to true but I don't see a
    ColumnHeaderValue property to fill them in
    and the header row seems to be the only one that gets 'framed'
    I'd like each row/column to have a 'frame' (dividing lines to show they are
    'paired up')

    then i thought maybe the column 2 is there but cant be seen, maybe i need to
    set the widths
    so i tried this in initialize sub
    ListBox1.ColumnCount = 2
    ListBox1.Column(1).ColumnWidth = ListBox1.Width / 2
    ListBox1.Column(2).ColumnWidth = ListBox1.Width / 2
    but get a run time error 424 Object Required (with nothing highlighted so
    don't know what line is erroring)

    and the same error with
    ListBox1.Column(0).ColumnWidth = ListBox1.Width / 2
    ListBox1.Column(1).ColumnWidth = ListBox1.Width / 2


    maybe i need to look at data grids?

    i'm lost! ":) (as usual)
    any help?
    tia
    mark
     
    MP, Aug 17, 2004
    #1
  2. MP

    MP Guest

    Thanks Jeff,
    I'll check that out
    Mark
     
    MP, Aug 17, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.