[MonoDevelop] Passing arguments to a constructor of a custom widget

Lluis Sanchez lluis at ximian.com
Mon Aug 13 08:09:17 EDT 2007


El dl 13 de 08 del 2007 a les 13:47 +0200, en/na Oliver Battenfeld va
escriure:
> Hi,
> 
> I have a class based on Gtk.DrawingArea which I want to use with
> MonoDevelop's GUI designer. The widget appears in the toolbox so I can
> drag it onto my form but the autogenerated code doesn't seem to care
> about the constructor arguments. 
> 
> My widget needs an instance of another class as a constructor
> argument:
> 
> class MyWidget : Gtk.DrawingArea {
> [...]
>     public MyWidget(Foo bar) {
>     [...]
>     }
> [...]
> }
> 
> The autogenerated code doesn't pass any argument like e.g.
> 
> myWidget = new MyWidget();
> 
> Is there a "nice" solution for this problem? Ideally, I'd like to be
> able to specify the constructor argument in the widget's property box
> (or something similar). 

Nope, it can't be done. You'll have to change your widget so that it has
a default constructor.

> 
> Thanks for your help!
> 
> Bonus question: I'm using two different PCs, both with MonoDevelop
> 0.14. One of them doesn't show MyWidget in the toolbox although I'm
> using the very same files. MyWidget also appears in the project
> settings under "GTK# settings" on both systems. Is there anyway to
> make MonoDevelop refresh the toolbox? Or is this more likely to be a
> bug? 

Maybe it is a bug, but before filing it you should check with MD 0.15,
since it might already be fixed.

Lluis.

> 



More information about the Monodevelop-list mailing list