c# - How to properly subclass an UserControl in this way? -
scenario
i have subclassed numericdown this:
public class mynumericupdown : inherits numericupdown ' more code here not matter... end class i compile usercontrol of windowsforms control library project have beneffit of usercontrol's property grid when debugging project.
problem
i can't find way compile numericdown want without breaking auto-generated usercontrol class of windowsforms control library project, means, breaking property grid feature , after compiling project having final exception message saying me dll: doesn't contain usercontrol types (but there , can add vs control toolbox).
question
in c# or vb, how can white windowsforms control library project show custom numericdown without loosing property grid feature?
i hope understand want.
i'll try in other words: test numericupdown in property grid, not usercontrol generated default windowsforms control library project.
it should "unit" when adding dll visualstudio control toolbox instead 2 separated controls.
code:
i don't have better show because can't find info start doing this.
public class usercontrol1 : inherits usercontrol public sub new() initializecomponent() ' not want, ' or @ least think shouldn't done this, ' want use , see custom numericupdown on property grid, ' not depending on usercontrol controllcollection. me.controls.add(new mynumericupdown) end sub end class
the test application shipped visual studio search controls derived usercontrol. if want able view/test other types need create custom application.
the following code proof of concept. easiest way implement full working application drop usercontroltestcontainer.exe onto decompiler reflector , copy code.
- create custom windows forms application , name
usercontroltestcontainer. - create shared sub main.
- uncheck
enable application framework, setstartup objectsub main. - when code looks mine, build.
public class form1 public sub new(optional byval args string() = nothing) me.initializecomponent() me.args = new label {.dock = dockstyle.fill, .text = if((args nothing), "(null)", string.join(environment.newline, args))} me.controls.add(me.args) end sub <stathread()> public shared sub main(optional byval args string() = nothing) application.enablevisualstyles() application.run(new form1(args)) end sub private args label end class - replace default
usercontroltestcontainer.exelocated inc:\program files (x86)\microsoft visual studio {version}\common7\idecustomusercontroltestcontainer.exe. - back in windows forms control library create custom control derived
control, hit run.

Comments
Post a Comment