Results 1 to 8 of 8

Thread: Create and populate listbox columns and rows with text strings...

  1. #1
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Create and populate listbox columns and rows with text strings...

    How on earth do you create and populate listbox columns and rows with text strings and place headers at the top at run time? I'm trying to get away from using a flexgrid control because you have to make sure the user has the OCX on their computer in order for it to work and that's becoming a problem lately. I hope that a listbox with columns can do almost the same thing. Can someone point me in the right direction with some simple code to do this? I've only reached the point of placing 6 columns in the listbox at design time but ".additem" only places text in the first column (at least that's what appears to be happening). Any help is appreciated. Thanks!

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: Create and populate listbox columns and rows with text strings...

    Correct, the AddItem method only populates the first column. After the row is added, fill in the additional columns as this snippet shows.
    Code:
                    lbxTitleBlock.AddItem strName
                    lbxTitleBlock.List(i - 1, 1) = strFile
                    lbxTitleBlock.List(i - 1, 2) = strMaj
                    lbxTitleBlock.List(i - 1, 3) = strMIn
                    lbxTitleBlock.List(i - 1, 4) = strGUID
    The listbox control does not have a column header like a datagrid. I suppose you could just populate the first row with column names. I just use trial and error to position labels above the listbox.
    C:> ED WORKING....


    LinkedIn

  3. #3
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: Create and populate listbox columns and rows with text strings...

    My listbox control (out of the box for AutoCAD 2006) has a "columnheader" Boolean property that allows them. They show up on top as blank boxes for now because I have no idea how to fill them in. When I use "additem" it places the text on the first row below the header line but it's still index "0".

    In your example, are you saying to "additem" the first column text first and then add the code you specified? I'm use to simply using Listbox1.additem "textstring". What is all the ibxTitleblock.list and strFile, strMaj stuff? Are these names and variables set by you or is this VBA code? Thanks for all the help by the way.

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Create and populate listbox columns and rows with text strings...

    In Ed's example, I would assume the lbxTitleBlock is the Listbox control. The .list is a property on the Listbox control. The strFile, strMaj stuff appear to be variables.

    HTH
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #5
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: Create and populate listbox columns and rows with text strings...

    The first line adds the item with text for the first column (index 0). The successive lines add values to each column in the row, as controlled by the var i.
    C:> ED WORKING....


    LinkedIn

  6. #6
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: Create and populate listbox columns and rows with text strings...

    Wow! That works great! Especially for what I need it for. One more quick question though. I can populate the first row but how do I populate the second row with a new set of values? If I used:

    ListBox1.List(i - 0, 1) = "Textstring"

    ..what does the "(i - 0,1) mean? I assumed the "0" was the index for the row and the "1" is the next column to put "Textstring" in but when I tried to add the next row by adding an item first and then using:

    ListBox1.List(i - 1, 1) = "Textstring2"

    ...I get an error for an invalid array. Thoughts?

  7. #7
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: Create and populate listbox columns and rows with text strings...

    The list is a 2 dimensional array. The first expression identifies the row, and the second expression identifies the column. Listing the columns is easy. You just need to supply a fixed integer corresponding to your column (zero based). For the row, you need to keep track of what row will be current when you perform the AddItem method. "i - #" is what I needed based upon the context of my code.
    Last edited by Ed Jobe; 2006-10-20 at 09:09 PM.
    C:> ED WORKING....


    LinkedIn

  8. #8
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Create and populate listbox columns and rows with text strings...

    Try this simle example and I hope that
    maybe this would be interesting to somebody else

    ~'J'~
    Attached Files Attached Files

Similar Threads

  1. Charts - Rows and Columns - Revit 2013
    By ROBP-RDS in forum Revit Architecture - General
    Replies: 9
    Last Post: 2015-06-09, 02:01 PM
  2. multiple rows and columns schedule
    By sami in forum Revit Architecture - General
    Replies: 1
    Last Post: 2010-02-28, 05:41 AM
  3. Hiding rows or columns
    By irneb in forum AutoCAD Tables
    Replies: 1
    Last Post: 2008-01-17, 07:37 PM
  4. Room Schedule with filtering by Columns and Rows?
    By dan.dankert in forum Revit Architecture - General
    Replies: 2
    Last Post: 2007-07-31, 07:59 PM
  5. Shading of rows/columns in schedules
    By Wes Macaulay in forum Revit Architecture - Wish List
    Replies: 3
    Last Post: 2006-06-28, 01:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •