Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the text of an NSTextView in Xamarin Mac?

OK, from the "I never expected THIS to be the hard part" department: how do I set the text of a NSTextField in Xamarin Mac?

  NSTextView view = new NSTextView(new RectangleF(0, 500, 200, 40));
  view.StringValue = "Foo";

does not compile (no method "StringValue"). Nor does SetStringValue("Foo"). Nor does there appear to be any SetText method. There's an InsertText method, but it doesn't take a C# string; it wants an NSObject (which makes me think it's not really intended for direct use).

Note that if I use NSTextField instead of NSTextView, I can assign to StringValue just fine. But with NSTextField, the same code fails.

I'm experienced in ObjC programming on iOS, but pretty much a noob to both Mac Cocoa and Xamarin Mac. So I'm sure I'm missing some obvious answer, but my googling hasn't found an answer (and the Xamarin forums are down today). Any help will be greatly appreciated.

like image 829
Joe Strout Avatar asked Apr 19 '14 13:04

Joe Strout


1 Answers

Have you tried the Value property?

http://forums.xamarin.com/discussion/14870/how-to-add-text-to-a-text-view-nstextview-in-a-nsscrollview-from-ib

like image 173
Jason Avatar answered Nov 12 '22 03:11

Jason