D
David Morris
I am very new to C# (a couple of hours) but have worked with Java for
quite a while. One thing that isn't obvious and I can't find in the
documentation is how to call the superclass/based on class constructor
in a subclass. I want to create a base button class that overrides some
properties. Here is what I have:
using System;
namespace zone
{
/// <summary>
/// Summary description for ZoneBaseButton.
/// </summary>
public class ZoneBaseButton : System.Windows.Forms.Button
{
private void InitializeComponent() {
//
// ZoneBaseButton
//
this.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.Font = new System.Drawing.Font("Microsoft Sans Serif",
20.25F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
}
public ZoneBaseButton()
{
//
// TODO: Add constructor logic here
//
}
}
}
I saved this in a class library and added it to the toolbox. When I use
it the base class properties are not used. Does this type of code belong
in the InitializeComponent method or would it go in the Constructor? Is
this even a reasonable approach?
Thank you,
David Morris
quite a while. One thing that isn't obvious and I can't find in the
documentation is how to call the superclass/based on class constructor
in a subclass. I want to create a base button class that overrides some
properties. Here is what I have:
using System;
namespace zone
{
/// <summary>
/// Summary description for ZoneBaseButton.
/// </summary>
public class ZoneBaseButton : System.Windows.Forms.Button
{
private void InitializeComponent() {
//
// ZoneBaseButton
//
this.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.Font = new System.Drawing.Font("Microsoft Sans Serif",
20.25F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
}
public ZoneBaseButton()
{
//
// TODO: Add constructor logic here
//
}
}
}
I saved this in a class library and added it to the toolbox. When I use
it the base class properties are not used. Does this type of code belong
in the InitializeComponent method or would it go in the Constructor? Is
this even a reasonable approach?
Thank you,
David Morris