S
Spurry Moses
Hi,
I'm converting a project from C++Builder to C# and I just need to copy my
class design across. It's looking good so far. To stick with the design I
want to inherit from a ComboBox control (ie MyComboBox). I don't need to
do anything flash with it, just add a few properties and methods. I'd
almost solved this while writing this post but I'll just confirm what I'm
doing is OK.
It was a bit awkward in Visual Studio because all of it's auto-generated
ways of creating controls use them as containers. And the one obvious
option that should have worked "Add inherited Control" failed looking for
"built assemblies". It must not be solution to my problem, I guess ;-)
Anyhow, to get my new control to show up in the toolbox, I have to "Add
User Control" and then delete all the code generated by it and replace it
with this.
public class MyComboBox : System.Windows.Forms.ComboBox
{
public MyComboBox() {
// TODO: Add any initialization after the InitializeComponent call
}
}
From there it basically seems to work. The combo box shows, I can put it
in the form and all seems well. Although I haven't tested it much yet. Is
there anything I'm missing like some Painting events might get screwed if
I don't add some method or anything?
I'll be happy if this is it!
I'm converting a project from C++Builder to C# and I just need to copy my
class design across. It's looking good so far. To stick with the design I
want to inherit from a ComboBox control (ie MyComboBox). I don't need to
do anything flash with it, just add a few properties and methods. I'd
almost solved this while writing this post but I'll just confirm what I'm
doing is OK.
It was a bit awkward in Visual Studio because all of it's auto-generated
ways of creating controls use them as containers. And the one obvious
option that should have worked "Add inherited Control" failed looking for
"built assemblies". It must not be solution to my problem, I guess ;-)
Anyhow, to get my new control to show up in the toolbox, I have to "Add
User Control" and then delete all the code generated by it and replace it
with this.
public class MyComboBox : System.Windows.Forms.ComboBox
{
public MyComboBox() {
// TODO: Add any initialization after the InitializeComponent call
}
}
From there it basically seems to work. The combo box shows, I can put it
in the form and all seems well. Although I haven't tested it much yet. Is
there anything I'm missing like some Painting events might get screwed if
I don't add some method or anything?
I'll be happy if this is it!