displaying image and multiple rows of text in NSTableView row

  • Hi,
    I'm using NSTableView for displaying.
    Now I need to show an icon in every row and also have to display 2
    rows of text in one row of tableView.
    Is it possible, if yes then how and can i incresse a row's width to
    accomodate two rows of text?
    OR
    if not possible, then can i use NSOutlineView for this purpose and how?

    Please help.

    Wishes,
    Nick
  • On Mar 3, 2008, at 6:34 AM, Nick Rogers wrote:
    > Hi,
    > I'm using NSTableView for displaying.
    > Now I need to show an icon in every row and also have to display 2
    > rows of text in one row of tableView.
    > Is it possible, if yes then how and can i incresse a row's width to
    > accomodate two rows of text?

    Two rows of text in a single row? Maybe you just want to use variable
    row heights. But then, that doesn't affect a row's width, which is
    always constant (it equals the width of the tableview).

    Maybe you want to increase the columns width?

    You can have a row span all columns with:

    /*  Optional - Different cells for each row
        A different data cell can be returned for any particular
    tableColumn and row, or a cell that will be used for the entire row (a
    full width cell). The returned cell should properly implement
    copyWithZone:, since the cell may be copied by NSTableView. If the
    tableColumn is non-nil, you should return a cell, and generally you
    will want to default to returning the result from [tableColumn
    dataCellForRow:row].

        When each row is being drawn, this method will first be called
    with a nil tableColumn. At this time, you can return a cell that will
    be used to draw the entire row, acting like a group. If you do return
    a cell for the 'nil' tableColumn, be prepared to have the other
    corresponding datasource and delegate methods to be called with a
    'nil' tableColumn value. If don't return a cell, the method will be
    called once for each tableColumn in the tableView, as usual.
    */
    - (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:
    (NSTableColumn *)tableColumn row:(NSInteger)row
    AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;

    -corbin

    >
    > OR
    > if not possible, then can i use NSOutlineView for this purpose and
    > how?
    >
  • On 3 Mar '08, at 6:34 AM, Nick Rogers wrote:

    > Now I need to show an icon in every row

    Add a new column and make its data cell an NSImageCell in IB.

    > and also have to display 2 rows of text in one row of tableView.
    > Is it possible, if yes then how and can i incresse a row's width to
    > accomodate two rows of text?

    You mean increase its *height*, don't you? Look at the NSTableView
    data-source API (in NSTableView.h) for the methods that let you
    specify custom row heights.

    —Jens
previous month march 2008 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today