Textwidth of an item in a listbox.

Discussion in 'AutoCAD' started by ntaylor, Sep 11, 2003.

  1. ntaylor

    ntaylor Guest

    I had this code to get the width of the text of an item in a listbox.

    Form1.TextWidth(List1.List(0))

    This worked for VB5 but not VBA. How can I get this width with VBA?

    Regards - Nathan
     
    ntaylor, Sep 11, 2003
    #1
  2. ntaylor

    ntaylor Guest

    Thanks Guys, It seems there is no easy way. I need to get the width of the longest item in the listbox so I can set the columnwidths property so my scrollbar is the correct length. My work around is to create the text item in word, set the font to be the same as the listbox and use the word textwidth property. Regards - Nathan
     
    ntaylor, Sep 12, 2003
    #2
  3. ntaylor

    joesu Guest

    Use a For loop to visit each item in the list and keep a variable holding the length of the longest item.

    Joe
    --
     
    joesu, Sep 12, 2003
    #3
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.