Display a nsoutlineview programmatically

1.1k views Asked by At

I want to display a simple nsoutlineview that will display a hierarchy.

When I did it via InterfaceBuilder, everything was fine, but now that I'm trying to it programmatically, I have some trouble.

Here the code I use to display the outline view, inside a nsscrollview :

this.OutlineView = new NSOutlineView();
this.OutlineView.IndentationPerLevel = 16.0f;
this.OutlineView.IndentationMarkerFollowsCell = true;
this.OutlineView.SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.Regular;
this.OutlineView.HeaderView = null;
this.OutlineView.BackgroundColor = NSColor.FromDeviceRgba(225f/255f,228f/255f,232f/255f,1f);
this.OutlineView.DataSource = dataSource;
this.OutlineView.Delegate = aDelegate;

NSTableColumn tableColumn = new NSTableColumn("Name");
tableColumn.Editable = false;
tableColumn.MinWidth = 100f;
this.OutlineView.AddColumn(tableColumn);

this.DocumentView = this.OutlineView;

And this is what I get when I want to display the hierarchy of a root directory and a file inside this directory :

enter image description here

No arrow before root, no indentation of the file in the directory...

1

There are 1 answers

0
AudioBubble On

Ok found it after looking in the debugger how xCode construct the scroll view :S

In addition to adding the table column, you have to set the OutlineTableColumn, by adding this line :

this.OutlineView.OutlineTableColumn = tableColumn;