Very strange !!!

  • Thread starter Thread starter Tamir Khason
  • Start date Start date
T

Tamir Khason

I create some user controls inherits from other controls (e.g. label,
button). But when I' using them from the other application some of them
works fine, but others (even the same type or just other instance of the
sample contorl) in compilation lose all its properties (include position and
others).

What is can be???
 
Sorry,
Follow the code of the one of controls with the same problem

public class TSButton : System.Windows.Forms.Label

{

private System.ComponentModel.IContainer components;

protected Color orig_bgColor = Color.FromArgb(206,231,206);

protected Color over_bgColor = Color.White;

protected Image onImage = null;

protected Image offImage = null;

protected Image disImage = null;

protected bool boldOnClick = false;

protected bool stateless = false;

protected bool enabled = true;

public TSButton()

{

InitializeComponent();

if (!DesignMode)

{

if (this.Image != null && this.Image != offImage)

{

this.Image = offImage;

}

if (onImage == null)

{

onImage = offImage;

}

}

if (!enabled)

{

if(disImage != null)

this.Image = disImage;

}

orig_bgColor = this.BackColor;



}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if(components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Component Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

//

// TSButton

//

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

this.ImageAlign = System.Drawing.ContentAlignment.TopCenter;

this.Size = new System.Drawing.Size(56, 80);

this.TextAlign = System.Drawing.ContentAlignment.BottomCenter;

this.Resize += new System.EventHandler(this.TSButton_Resize);

this.MouseUp += new
System.Windows.Forms.MouseEventHandler(this.TSButton_MouseUp);

this.MouseDown += new
System.Windows.Forms.MouseEventHandler(this.TSButton_MouseDown);

}

#endregion

protected void imageDes()

{

if (this.Image != null && this.Image != offImage)

{

this.Image = offImage;

}

if (onImage == null)

{

onImage = offImage;

}

}



public Image OnImage

{

set

{

onImage = value;



}

get

{

return onImage;

}

}

public Image OffImage

{

set

{

offImage = value;

if (DesignMode)

this.Size = new Size(offImage.Size.Width,offImage.Size.Height + 4
+Convert.ToInt16(this.Font.GetHeight()));

this.Image = offImage;

if(DesignMode && onImage == null)

{

onImage = offImage;

}

}

get

{

return offImage;

}

}

public Image DisableImage

{

set

{

disImage = value;



}

get

{

return disImage;

}

}

public Color OverColor

{

set

{

over_bgColor = value;

}

get

{

return over_bgColor;

}

}

public bool BoldOnClick

{

get

{

return boldOnClick;

}

set

{

boldOnClick = value;

}

}

public bool Stateless

{

get

{

return stateless;

}

set

{

stateless = value;

}

}

public new bool Enabled

{

get

{

return enabled;

}

set

{

enabled = value;

}

}

protected override void OnClick(EventArgs e)

{

if(enabled)

{

if (!stateless && this.Image == onImage)

{

this.Image = offImage;

this.BackColor = orig_bgColor;


}

else

{

this.Image = onImage;

this.BackColor = over_bgColor;

}

base.OnClick (e);

this.Invalidate();

}

}

public void shutdown()

{

this.Image = offImage;

this.BackColor = orig_bgColor;

}

protected override void OnBackColorChanged(EventArgs e)

{

base.OnBackColorChanged (e);

if (!DesignMode)

{

if (this.BackColor != over_bgColor && this.BackColor != orig_bgColor)

{

orig_bgColor = this.BackColor;

}

}


}

private void TSButton_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)

{

if(enabled)

{

if(stateless)

{

this.Image = onImage;

this.BackColor = over_bgColor;

}

}

}

private void TSButton_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)

{



if(stateless)

{

this.Image = offImage;

this.BackColor = orig_bgColor;



}



}

private void TSButton_Resize(object sender, System.EventArgs e)

{


}

}
 
Tamir,

Just to be funny, your post is about the same as asking:
"My car is making a strange sound. What could be causing it?"

Ok, seriously. Post an example so that we can help.
 
Back
Top