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.

  1. create custom windows forms application , name usercontroltestcontainer.
  2. create shared sub main.
  3. uncheck enable application framework , set startup object sub main.
  4. 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 
  1. replace default usercontroltestcontainer.exe located in c:\program files (x86)\microsoft visual studio {version}\common7\ide custom usercontroltestcontainer.exe.
  2. back in windows forms control library create custom control derived control , hit run.

custom usercontrol test container


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

wordpress - .htaccess: RewriteRule: bad flag delimiters -

c# - MSAA finds controls UI Automation doesn't -