[Mono-osx] Dynamically add User Control (SubView) defined in the Nib

Tomas Trescak tomi.trescak at gmail.com
Wed Dec 14 05:47:16 EST 2011


Got it working.
The problem was that I was using directly the View, not the contoroller.
So instead of:

SubView sb = new SubView (box.Handle); // subview is the monomac code 
generated to my nib
sb.SetFrameOrigin (new PointF (0, 100));
box.AddSubview(sb); // box the the NSView contorl type box

Should have been:

SubViewController widget = new SubViewController ();
widget.View.SetFrameOrigin (new PointF (0, 0));
box.AddSubview (widget.View);

Thanks for your help

Tomas

初音センケン wrote:
>
>
> I think "AddSubview" is the right approach. If it doesn't work, try
> "SetFrameOrigin" to set the subview to a right position. Be noticed
> that the Mac's screen coordinate is different from Windows or iOS,
> which starts from the left-bottom corner of the screen (WIN or iOS
> start from left-top corner).
>
> I'm new to MonoMac too, hope it helps.
> ------------------ Original ------------------
> *From: * "Tomas Trescak"<tomi.trescak at gmail.com>;
> *Date: * Wed, Dec 14, 2011 05:32 PM
> *To: * "mono-osx"<mono-osx at lists.ximian.com>;
> *Subject: * [Mono-osx] Dynamically add User Control (SubView) defined
> in the Nib
> Dears
>
> I'm very new to the Cocoa - Objective C programming, but I have more
> than 8 years of c# programming.
> My problem is following:
>
> How do I dynamically add a new user control (Cocoa control) to the
> interface.
> The control is defined in the NIB (.nix) file.
> I could not do this nor in the Interface Designer, nor in the program
> code.
> For the "Groupbox" control I have found a method "AddSubview" which does
> nothing, but I'm just probably not using it right.
>
> Any ideas are greatly appreciated
>
> Have a wonderful day
>
> Tomas
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
>
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20111214/56c44d8a/attachment.html 


More information about the Mono-osx mailing list