G
Guest
ive got a user control in vs2003 v1.1, below is the general overview,
hopefully its enough....
my problem is, and im not even sure its a problem, is it appears the resize
event is firing multiple times and im not sure if that behavior is correct or
im causing it. if i set one of the captions on my label to 0 and then
increment it by one in the resize event, when i load the application that has
1 of this meter control on it, the label value goes from 0 to 8 meaning the
resize event fired 8 times. is this right or am i causing this or am i
supposed to have some code in there?
in design time when i lay the control on the form, the increment only goes
to 1 or if i toggle a property i have at runtime which calls the resize
event, it also only increments 1.
public class Meter : System.Windows.Forms.Control
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
//--------------------------------------------------
Label lblTop=new Label();
Label lblLeft=new Label();
Label lblRight=new Label();
Label lblValue=new Label();
ComboBox cmbSelection=new ComboBox();
.....lot more vars here
//--------------------------------------------------
public Meter()
{
// This call is required by the Windows.Forms Designer.
InitializeComponent();
//build the controls for the meter-location will be handled in the resize
event, we dont care about the location at this point
//meter top
lblTop.Size=new System.Drawing.Size(105,14);
lblTop.Font=new Font("Tahoma", 8, FontStyle.Bold);
lblTop.BackColor=m_captionBackColor;
lblTop.ForeColor=m_captionForeColor;
lblTop.TextAlign=m_captionAlignment;
lblTop.Text=m_caption;
this.Controls.Add(lblTop);
....build the controls
//call the resize event so stuff gets aligned right
this.Size=new System.Drawing.Size(lblTop.Width,height);
protected override void OnResize(EventArgs e)
{
....here i make calls to adjust Location, Size, and Font
hopefully its enough....
my problem is, and im not even sure its a problem, is it appears the resize
event is firing multiple times and im not sure if that behavior is correct or
im causing it. if i set one of the captions on my label to 0 and then
increment it by one in the resize event, when i load the application that has
1 of this meter control on it, the label value goes from 0 to 8 meaning the
resize event fired 8 times. is this right or am i causing this or am i
supposed to have some code in there?
in design time when i lay the control on the form, the increment only goes
to 1 or if i toggle a property i have at runtime which calls the resize
event, it also only increments 1.
public class Meter : System.Windows.Forms.Control
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
//--------------------------------------------------
Label lblTop=new Label();
Label lblLeft=new Label();
Label lblRight=new Label();
Label lblValue=new Label();
ComboBox cmbSelection=new ComboBox();
.....lot more vars here
//--------------------------------------------------
public Meter()
{
// This call is required by the Windows.Forms Designer.
InitializeComponent();
//build the controls for the meter-location will be handled in the resize
event, we dont care about the location at this point
//meter top
lblTop.Size=new System.Drawing.Size(105,14);
lblTop.Font=new Font("Tahoma", 8, FontStyle.Bold);
lblTop.BackColor=m_captionBackColor;
lblTop.ForeColor=m_captionForeColor;
lblTop.TextAlign=m_captionAlignment;
lblTop.Text=m_caption;
this.Controls.Add(lblTop);
....build the controls
//call the resize event so stuff gets aligned right
this.Size=new System.Drawing.Size(lblTop.Width,height);
protected override void OnResize(EventArgs e)
{
....here i make calls to adjust Location, Size, and Font