Problem with my custom button

Mar 24 2006 4:39 AM

Hello everyone!
I have a problem with my custom created buton.

I create a property ButtonIcon which define icon and text for my button. Icons I have saved in resources.

When I add my button to form all works fine. But when I change icon or text on button, this doesn't affect on form.
I noticed that when I add button to form there is created some code in  InitializeComponent() which set Image and Text for my button localy on the form.

Code on form:
private void InitializeComponent()
{
......
this.crButton1 = new CRing.Controls.CRButton();
this.SuspendLayout();

// this is my created property 
this.crButton1.ButtonIcon = CRing.Controls.ButtonIcons.Cancel;

// this two lines below are my problem  !!!!!!!!!!!
// before this lines values for Text and Image are ok, but here are always set to local values

this.crButton1.Image = ((System.Drawing.Image)(resources.GetObject("crButton1.Image")));
this.crButton1.Text = "Preklici";

this.crButton1.Size = new System.Drawing.Size(93, 23);
this.crButton1.TabIndex = 0;
this.crButton1.UseVisualStyleBackColor = true;
.........

I want to achive, that icon (Image) and Text always takes from my button and not localy from InitializeComonents() on form.

How can I prevent creating code on form for this two properties?
this.crButton1.Image = ((System.Drawing.Image)(resources.GetObject
("crButton1.Image")));
this.crButton1.Text = "Cancel";

If I comment this two lines all works fine like I wish, but I don't want always take care of this.

Please help!

Sorry my english!

Thanks, Jure

 


Answers (1)