I've created a custom control, based on the Picturebox:
public class Timebar : System.Windows.Forms.PictureBox
This works correctly if I create the control manually/set all values etc. etc, at the Form's initialization method.
Now I also found this, at the top of the Toolbox: http://i.imgur.com/4KUc0.png
When I try to insert it via msvc, I get an error however.
Failed to create component 'Timebar'. The error message follows:
'System.MissingMethodException: Constructor on type 'SC.Timebar' not found.
This isn't exactly a huge problem with my component Timebar (as I will add that component manually), but it is with the custom Button class I want to make (something more fancy then the default).
There IS a constructor in the class:
public Timebar(Data refr)
{
this._refr = refr;
}
How can I fix the above error?
Thanks,
~ Tgys
Controls used in the designer must have a parameterless constructor. The designer needs to create one of your controls to display and allow you to manipulate it, but it has no clue as to how it should call a constructor that requires parameters.
So, what I would do is create a parameterless constructor which chains the other constructor using a default value, i.e.,
class Foo
{
public Foo() : this(SomeType.Value) { }
public Foo(SomeType whatever) : { /* do stuff /* }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With