NSTableColumn autosizing to fit

Discussion in 'Mac Programming' started by McBgnr, Jun 3, 2009.

  1. macrumors regular

    Joined:
    Apr 13, 2009
    #1
    Hello,

    I have a NSTableView which has 2 columns. First columns contains strings. Some of these strings are long and are not visible completely in the column. I have also added HorizontalScroll bar to the TableView but no use. It scrolls the contents of the TableView but not of the column.

    How can I request TableColumn to resize so that the longest string is the column is completely visible. The min and max width parameters of the TableColumn are set correctly. I have also tried using the Col. Sizing style but it did not help either. Any suggestions?
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    I don't think there's a built-in way to do this, if I'm understanding it correctly. You could just use NSAttributedString to get the width of the string at the font (via the tablecolumn's datacell) and then set the column's width to that (plus a bit more probably for spacing).
     
  3. thread starter macrumors regular

    Joined:
    Apr 13, 2009
    #3
    I was wondering that there might be some built in way for this :-(. I will give a try to the other method using the attributed string.
     

Share This Page