Customized components

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • styko

    #1

    Customized components

    I'd like to create a customized button- so I've written something like this



    public class TestButton : Button

    {

    public TestButton() : base()

    {

    this.BackColor = System.Drawing. Color.FromArgb( ((System.Byte)( 100)),
    ((System.Byte)( 114)), ((System.Byte)( 138)));

    this.FlatStyle = System.Windows. Forms.FlatStyle .Flat;

    this.ForeColor = System.Drawing. Color.White;

    this.Size = new System.Drawing. Size(96, 23);

    this.TabIndex = 0;

    }

    }



    I have compiled it into separate .dll because I want to be able t change
    look & feel of buttons in client application without recompiling it (only by
    replacing the .dll)



    But now when I drag & drop my new button from the toolbox onto my form the
    environment generates following code in the InicializeCompo nents() method:



    ..

    this.TestButton 2 = new TestButton();

    this.TestButton 2.BackColor =
    System.Drawing. Color.FromArgb( ((System.Byte)( 100)), ((System.Byte)( 114)),
    ((System.Byte)( 138)));

    this.TestButton 2.FlatStyle = System.Windows. Forms.FlatStyle .Flat;

    this.TestButton 2.ForeColor = System.Drawing. Color.White;

    this.TestButton 2.Location = new System.Drawing. Point(72, 72);

    this.TestButton 2.Name = "sputnikButton2 ";

    this.TestButton 2.Size = new System.Drawing. Size(96, 23);

    this.TestButton 2.TabIndex = 0;

    this.TestButton 2.Text = "sputnikButton2 ";

    ..



    so it duplicates the code from TestButton constructor. Now when I change for
    example BackColor property in my TestButton and replace it's .dll in the
    client application it will not take effect because the settings in the
    constructor are overridden by code generated by VS environment.

    How can I fix it???



    Thanks in advance for any help!








Working...