0

I use simple NSTableViewDelegate , inside GetViewForItem method I find with with Identifier

NSTableCellView view = (NSTableCellView)tableView.MakeView (tableColumn.Identifier, this);

If Identifier is "Img" view should contain ImageView :

switch (tableColumn.Identifier) {
                case "Img":
                    var imageData = DataSource.Patients [(int)row].getImageData ();
                    if (imageData != null) {
                        view.ImageView.Image = new NSImage (imageData);
                    } else {
                        view.ImageView.Image = NSImage.ImageNamed ("client.png");
                    }
                    tableColumn.HeaderCell.BackgroundStyle = NSBackgroundStyle.Dark;
                    break;
                }

but view.ImageView is null

here is screenshot from xcode, how Img cell looks like:

enter image description here

Nininea
  • 2,671
  • 6
  • 31
  • 57

1 Answers1

1

Did you connect the ImageView to the Table Cell View imageView outlet in xcode?

Click/select the Table Cell View. In the properties panel select the outlets tab (the one with the arrow to the right in a circle). Drag the little circle behind the imageView outlet to your imageview and release.

svn
  • 1,235
  • 10
  • 22
  • one more question @svn, I need to connect action to this image view, I added action in xcode, but it is not called. do you have any idea? – Nininea Oct 31 '16 at 11:16
  • image view does not support click action (use NSButton for that). It does support an action when a user drags an image on to if (if the imageview is set to editable). Never used this thought. I never use actions in xcode. But always subscribe to an event on the control in c#. For the default action this is the Activated event. – svn Oct 31 '16 at 12:12
  • yeap, it works... here is my new question, if you can write answer – Nininea Oct 31 '16 at 12:21