473,609 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UserControl and Fliker - Take 2

Hi everyone !

For those who haven't read my previous post, I have a problem with a
UserControl. When I try to display it on a form, controls seem to
appear one after one. In the following example, it's less visible
because controls don't execute any code... Is someone has an idea of
how I could solve this problem and also improve the method
ShowUserControl . I try to figure out I could flicker effect when I
press the button twice quickly.

Thanks for your help !

----- Form1.cs -----
using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;

namespace WindowsApplicat ion2
{
public class Form1 : Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.splitConta iner1 = new
System.Windows. Forms.SplitCont ainer();
this.button1 = new System.Windows. Forms.Button();
this.splitConta iner1.Panel2.Su spendLayout();
this.splitConta iner1.SuspendLa yout();
this.SuspendLay out();
//
// splitContainer1
//
this.splitConta iner1.Dock =
System.Windows. Forms.DockStyle .Fill;
this.splitConta iner1.Location = new System.Drawing. Point(0,
0);
this.splitConta iner1.Name = "splitContainer 1";
//
// splitContainer1 .Panel2
//
this.splitConta iner1.Panel2.Co ntrols.Add(this .button1);
this.splitConta iner1.Size = new System.Drawing. Size(642,
305);
this.splitConta iner1.SplitterD istance = 425;
this.splitConta iner1.TabIndex = 0;
//
// button1
//
this.button1.Lo cation = new System.Drawing. Point(21, 22);
this.button1.Na me = "button1";
this.button1.Si ze = new System.Drawing. Size(75, 23);
this.button1.Ta bIndex = 0;
this.button1.Te xt = "button1";
this.button1.Us eVisualStyleBac kColor = true;
this.button1.Cl ick += new
System.EventHan dler(this.butto n1_Click);
//
// Form1
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F,
13F);
this.AutoScaleM ode =
System.Windows. Forms.AutoScale Mode.Font;
this.ClientSize = new System.Drawing. Size(642, 305);
this.Controls.A dd(this.splitCo ntainer1);
this.Name = "Form1";
this.Text = "Form1";
this.splitConta iner1.Panel2.Re sumeLayout(fals e);
this.splitConta iner1.ResumeLay out(false);
this.ResumeLayo ut(false);

}

#endregion

private System.Windows. Forms.SplitCont ainer splitContainer1 ;
private System.Windows. Forms.Button button1;
public Form1()
{
InitializeCompo nent();
}

private void ShowUserControl (UserControl _objUserControl ,
Control _objContainer)
{
_objUserControl .Location = new Point(0, 0);
_objUserControl .Size =
new Size(_objContai ner.Width, _objContainer.H eight);
_objUserControl .Anchor = AnchorStyles.To p |
AnchorStyles.Bo ttom |
AnchorStyles.Le ft |
AnchorStyles.Ri ght;

_objContainer.S uspendLayout();

_objContainer.C ontrols.Clear() ;
_objContainer.C ontrols.Add(_ob jUserControl);

_objContainer.R esumeLayout();
}

private void button1_Click(o bject sender, EventArgs e)
{
ShowUserControl (new UserControl1(),
splitContainer1 .Panel1);
}
}
}

---- UserControl1.cs ----
using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows. Forms;

namespace WindowsApplicat ion2
{
public class UserControl1 : UserControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#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 InitializeCompo nent()
{
this.components = new System.Componen tModel.Containe r();
this.tableLayou tPanel = new
System.Windows. Forms.TableLayo utPanel();
this.txtStreet = new System.Windows. Forms.TextBox() ;
this.txtCity = new System.Windows. Forms.TextBox() ;
this.ddlState = new System.Windows. Forms.ComboBox( );
this.ddlCountry = new System.Windows. Forms.ComboBox( );
this.txtPostalC ode = new System.Windows. Forms.TextBox() ;
this.lblStreet = new System.Windows. Forms.Label();
this.lblCity = new System.Windows. Forms.Label();
this.lblStatePr ovince = new System.Windows. Forms.Label();
this.lblPostalC ode = new System.Windows. Forms.Label();
this.lblCountry = new System.Windows. Forms.Label();
this.errorProvi der = new
System.Windows. Forms.ErrorProv ider(this.compo nents);
this.tableLayou tPanel.SuspendL ayout();

((System.Compon entModel.ISuppo rtInitialize)(t his.errorProvid er)).BeginInit( );
this.SuspendLay out();
//
// tableLayoutPane l1
//
this.tableLayou tPanel.Anchor =
((System.Window s.Forms.AnchorS tyles)(((System .Windows.Forms. AnchorStyles.To p
| System.Windows. Forms.AnchorSty les.Left)
| System.Windows. Forms.AnchorSty les.Right)));
this.tableLayou tPanel.ColumnCo unt = 2;
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Absolute,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.Controls .Add(this.txtSt reet, 1, 2);
this.tableLayou tPanel.Controls .Add(this.txtCi ty, 1, 3);
this.tableLayou tPanel.Controls .Add(this.ddlSt ate, 1, 4);
this.tableLayou tPanel.Controls .Add(this.ddlCo untry, 1, 1);
this.tableLayou tPanel.Controls .Add(this.txtPo stalCode, 1,
5);
this.tableLayou tPanel.Controls .Add(this.lblSt reet, 0, 2);
this.tableLayou tPanel.Controls .Add(this.lblCi ty, 0, 3);
this.tableLayou tPanel.Controls .Add(this.lblSt ateProvince,
0, 4);
this.tableLayou tPanel.Controls .Add(this.lblPo stalCode, 0,
5);
this.tableLayou tPanel.Controls .Add(this.lblCo untry, 0, 1);
this.tableLayou tPanel.Location = new
System.Drawing. Point(0, 0);
this.tableLayou tPanel.Margin = new
System.Windows. Forms.Padding(0 , 3, 0, 3);
this.tableLayou tPanel.Name = "tableLayoutPan el";
this.tableLayou tPanel.RowCount = 6;
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( System.Windows. Forms.SizeType. Absolute,
15F));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.Size = new System.Drawing. Size(618,
165);
this.tableLayou tPanel.TabIndex = 0;
//
// txtStreet
//
this.txtStreet. Dock = System.Windows. Forms.DockStyle .Fill;
this.errorProvi der.SetIconAlig nment(this.txtS treet,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.txtStreet. Location = new System.Drawing. Point(103,
45);
this.txtStreet. MinimumSize = new System.Drawing. Size(4,
26);
this.txtStreet. Multiline = true;
this.txtStreet. Name = "txtStreet" ;
this.txtStreet. ScrollBars =
System.Windows. Forms.ScrollBar s.Vertical;
this.txtStreet. Size = new System.Drawing. Size(512, 32);
this.txtStreet. TabIndex = 1;
//
// txtCity
//
this.txtCity.Do ck = System.Windows. Forms.DockStyle .Fill;
this.errorProvi der.SetIconAlig nment(this.txtC ity,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.txtCity.Lo cation = new System.Drawing. Point(103, 83);
this.txtCity.Na me = "txtCity";
this.txtCity.Si ze = new System.Drawing. Size(512, 20);
this.txtCity.Ta bIndex = 2;
//
// ddlState
//
this.ddlState.D ock = System.Windows. Forms.DockStyle .Fill;
this.ddlState.D ropDownStyle =
System.Windows. Forms.ComboBoxS tyle.DropDownLi st;
this.ddlState.F ormattingEnable d = true;
this.errorProvi der.SetIconAlig nment(this.ddlS tate,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.ddlState.L ocation = new System.Drawing. Point(103,
109);
this.ddlState.N ame = "ddlState";
this.ddlState.S ize = new System.Drawing. Size(512, 21);
this.ddlState.T abIndex = 3;
//
// ddlCountry
//
this.ddlCountry .Dock = System.Windows. Forms.DockStyle .Fill;
this.ddlCountry .DropDownStyle =
System.Windows. Forms.ComboBoxS tyle.DropDownLi st;
this.ddlCountry .FormattingEnab led = true;
this.errorProvi der.SetIconAlig nment(this.ddlC ountry,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.ddlCountry .Location = new System.Drawing. Point(103,
18);
this.ddlCountry .Name = "ddlCountry ";
this.ddlCountry .Size = new System.Drawing. Size(512, 21);
this.ddlCountry .TabIndex = 0;
//
// txtPostalCode
//
this.txtPostalC ode.Dock =
System.Windows. Forms.DockStyle .Fill;
this.errorProvi der.SetIconAlig nment(this.txtP ostalCode,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.txtPostalC ode.Location = new System.Drawing. Point(103,
136);
this.txtPostalC ode.Name = "txtPostalCode" ;
this.txtPostalC ode.Size = new System.Drawing. Size(512, 20);
this.txtPostalC ode.TabIndex = 4;
//
// lblStreet
//
this.lblStreet. AutoSize = true;
this.lblStreet. Dock = System.Windows. Forms.DockStyle .Fill;
this.lblStreet. ImeMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblStreet. Location = new System.Drawing. Point(3, 42);
this.lblStreet. Name = "lblStreet" ;
this.lblStreet. Size = new System.Drawing. Size(94, 38);
this.lblStreet. TabIndex = 0;
this.lblStreet. Text = "lblStreet" ;
this.lblStreet. TextAlign =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// lblCity
//
this.lblCity.Au toSize = true;
this.lblCity.Do ck = System.Windows. Forms.DockStyle .Fill;
this.lblCity.Im eMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblCity.Lo cation = new System.Drawing. Point(3, 80);
this.lblCity.Na me = "lblCity";
this.lblCity.Si ze = new System.Drawing. Size(94, 26);
this.lblCity.Ta bIndex = 0;
this.lblCity.Te xt = "lblCity";
this.lblCity.Te xtAlign =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// lblStateProvinc e
//
this.lblStatePr ovince.AutoSize = true;
this.lblStatePr ovince.Dock =
System.Windows. Forms.DockStyle .Fill;
this.lblStatePr ovince.ImeMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblStatePr ovince.Location = new
System.Drawing. Point(3, 106);
this.lblStatePr ovince.Name = "lblStateProvin ce";
this.lblStatePr ovince.Size = new System.Drawing. Size(94,
27);
this.lblStatePr ovince.TabIndex = 0;
this.lblStatePr ovince.Text = "lblStateProvin ce";
this.lblStatePr ovince.TextAlig n =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// lblPostalCode
//
this.lblPostalC ode.AutoSize = true;
this.lblPostalC ode.Dock =
System.Windows. Forms.DockStyle .Fill;
this.lblPostalC ode.ImeMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblPostalC ode.Location = new System.Drawing. Point(3,
133);
this.lblPostalC ode.Name = "lblPostalCode" ;
this.lblPostalC ode.Size = new System.Drawing. Size(94, 32);
this.lblPostalC ode.TabIndex = 0;
this.lblPostalC ode.Text = "lblPostalCode" ;
this.lblPostalC ode.TextAlign =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// lblCountry
//
this.lblCountry .AutoSize = true;
this.lblCountry .Dock = System.Windows. Forms.DockStyle .Fill;
this.lblCountry .ImeMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblCountry .Location = new System.Drawing. Point(3, 15);
this.lblCountry .Name = "lblCountry ";
this.lblCountry .Size = new System.Drawing. Size(94, 27);
this.lblCountry .TabIndex = 0;
this.lblCountry .Text = "lblCountry ";
this.lblCountry .TextAlign =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// errorProvider
//
this.errorProvi der.ContainerCo ntrol = this;
//
// AddressUC
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F,
13F);
this.AutoScaleM ode =
System.Windows. Forms.AutoScale Mode.Font;
this.Controls.A dd(this.tableLa youtPanel);
this.DoubleBuff ered = true;
this.Name = "AddressUC" ;
this.Size = new System.Drawing. Size(618, 176);
this.tableLayou tPanel.ResumeLa yout(false);
this.tableLayou tPanel.PerformL ayout();

((System.Compon entModel.ISuppo rtInitialize)(t his.errorProvid er)).EndInit();
this.ResumeLayo ut(false);

}

#endregion

private System.Windows. Forms.TableLayo utPanel tableLayoutPane l;
private System.Windows. Forms.TextBox txtStreet;
private System.Windows. Forms.TextBox txtCity;
private System.Windows. Forms.ComboBox ddlState;
private System.Windows. Forms.ComboBox ddlCountry;
private System.Windows. Forms.TextBox txtPostalCode;
private System.Windows. Forms.Label lblStreet;
private System.Windows. Forms.Label lblCity;
private System.Windows. Forms.Label lblStateProvinc e;
private System.Windows. Forms.Label lblPostalCode;
private System.Windows. Forms.Label lblCountry;
private System.Windows. Forms.ErrorProv ider errorProvider;

public UserControl1()
{
InitializeCompo nent();
}
}
}

Dec 12 '06 #1
4 2460

Martin wrote:
In the following example, it's less visible
because controls don't execute any code...
I assume you mean "code in their constructors". What code are you
executing in the controls' constructors? You should do the minimum
amount of work in constructors and do as much of the heavy lifting as
you can when the control is loaded.

Dec 12 '06 #2
Hi Bruce,

It's exactly what I mean... Controls don't have any code in their
constructor, OnLoad, etc. Usually, the Country ComboBox load from a SQL
Server Database a list of Countries. The same for the State ComboBox,
but it waits for the Country ComboBox to load its list of state. These
operations are fast...

In my case, controls come out in the following order : txtStreet,
txtCity, txtPostalCode, ddlCountry and ddlState...

Thanks

Bruce Wood wrote:
Martin wrote:
In the following example, it's less visible
because controls don't execute any code...

I assume you mean "code in their constructors". What code are you
executing in the controls' constructors? You should do the minimum
amount of work in constructors and do as much of the heavy lifting as
you can when the control is loaded.
Dec 12 '06 #3
Hi Martin,

Well this time I was able to build the solution :)

I think I see the flicker you're referring to, but it's awfully fast on my
computer. TableLayoutPane l is usually the problem, although it still
renders quickly for such a small control.

It sounds to me like it might be your data-access code that is the bottle
neck (you mentioned it in another post in this thread). If so you might
want to use asynchronous calls to the database or use a BackgroundWorke r
component to free up the UI thread while it's loading.

Actually, a better question would be, how much flicker is there? What
exactly do you mean by "appear one after one"? Is it painfully obvious or
is it so quick that it's easy to miss (as in my testing)?

To be perfectly honest, if it's really fast then I don't think that there's
anything you can do about it. That's the price you pay when using Controls
to ease development.

--
Dave Sexton

"Martin" <ma*********@gm ail.comwrote in message
news:11******** **************@ j72g2000cwa.goo glegroups.com.. .
Hi everyone !

For those who haven't read my previous post, I have a problem with a
UserControl. When I try to display it on a form, controls seem to
appear one after one. In the following example, it's less visible
because controls don't execute any code... Is someone has an idea of
how I could solve this problem and also improve the method
ShowUserControl . I try to figure out I could flicker effect when I
press the button twice quickly.

Thanks for your help !

----- Form1.cs -----
using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;

namespace WindowsApplicat ion2
{
public class Form1 : Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.splitConta iner1 = new
System.Windows. Forms.SplitCont ainer();
this.button1 = new System.Windows. Forms.Button();
this.splitConta iner1.Panel2.Su spendLayout();
this.splitConta iner1.SuspendLa yout();
this.SuspendLay out();
//
// splitContainer1
//
this.splitConta iner1.Dock =
System.Windows. Forms.DockStyle .Fill;
this.splitConta iner1.Location = new System.Drawing. Point(0,
0);
this.splitConta iner1.Name = "splitContainer 1";
//
// splitContainer1 .Panel2
//
this.splitConta iner1.Panel2.Co ntrols.Add(this .button1);
this.splitConta iner1.Size = new System.Drawing. Size(642,
305);
this.splitConta iner1.SplitterD istance = 425;
this.splitConta iner1.TabIndex = 0;
//
// button1
//
this.button1.Lo cation = new System.Drawing. Point(21, 22);
this.button1.Na me = "button1";
this.button1.Si ze = new System.Drawing. Size(75, 23);
this.button1.Ta bIndex = 0;
this.button1.Te xt = "button1";
this.button1.Us eVisualStyleBac kColor = true;
this.button1.Cl ick += new
System.EventHan dler(this.butto n1_Click);
//
// Form1
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F,
13F);
this.AutoScaleM ode =
System.Windows. Forms.AutoScale Mode.Font;
this.ClientSize = new System.Drawing. Size(642, 305);
this.Controls.A dd(this.splitCo ntainer1);
this.Name = "Form1";
this.Text = "Form1";
this.splitConta iner1.Panel2.Re sumeLayout(fals e);
this.splitConta iner1.ResumeLay out(false);
this.ResumeLayo ut(false);

}

#endregion

private System.Windows. Forms.SplitCont ainer splitContainer1 ;
private System.Windows. Forms.Button button1;
public Form1()
{
InitializeCompo nent();
}

private void ShowUserControl (UserControl _objUserControl ,
Control _objContainer)
{
_objUserControl .Location = new Point(0, 0);
_objUserControl .Size =
new Size(_objContai ner.Width, _objContainer.H eight);
_objUserControl .Anchor = AnchorStyles.To p |
AnchorStyles.Bo ttom |
AnchorStyles.Le ft |
AnchorStyles.Ri ght;

_objContainer.S uspendLayout();

_objContainer.C ontrols.Clear() ;
_objContainer.C ontrols.Add(_ob jUserControl);

_objContainer.R esumeLayout();
}

private void button1_Click(o bject sender, EventArgs e)
{
ShowUserControl (new UserControl1(),
splitContainer1 .Panel1);
}
}
}

---- UserControl1.cs ----
using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows. Forms;

namespace WindowsApplicat ion2
{
public class UserControl1 : UserControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#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 InitializeCompo nent()
{
this.components = new System.Componen tModel.Containe r();
this.tableLayou tPanel = new
System.Windows. Forms.TableLayo utPanel();
this.txtStreet = new System.Windows. Forms.TextBox() ;
this.txtCity = new System.Windows. Forms.TextBox() ;
this.ddlState = new System.Windows. Forms.ComboBox( );
this.ddlCountry = new System.Windows. Forms.ComboBox( );
this.txtPostalC ode = new System.Windows. Forms.TextBox() ;
this.lblStreet = new System.Windows. Forms.Label();
this.lblCity = new System.Windows. Forms.Label();
this.lblStatePr ovince = new System.Windows. Forms.Label();
this.lblPostalC ode = new System.Windows. Forms.Label();
this.lblCountry = new System.Windows. Forms.Label();
this.errorProvi der = new
System.Windows. Forms.ErrorProv ider(this.compo nents);
this.tableLayou tPanel.SuspendL ayout();

((System.Compon entModel.ISuppo rtInitialize)(t his.errorProvid er)).BeginInit( );
this.SuspendLay out();
//
// tableLayoutPane l1
//
this.tableLayou tPanel.Anchor =
((System.Window s.Forms.AnchorS tyles)(((System .Windows.Forms. AnchorStyles.To p
| System.Windows. Forms.AnchorSty les.Left)
| System.Windows. Forms.AnchorSty les.Right)));
this.tableLayou tPanel.ColumnCo unt = 2;
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Absolute,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.Controls .Add(this.txtSt reet, 1, 2);
this.tableLayou tPanel.Controls .Add(this.txtCi ty, 1, 3);
this.tableLayou tPanel.Controls .Add(this.ddlSt ate, 1, 4);
this.tableLayou tPanel.Controls .Add(this.ddlCo untry, 1, 1);
this.tableLayou tPanel.Controls .Add(this.txtPo stalCode, 1,
5);
this.tableLayou tPanel.Controls .Add(this.lblSt reet, 0, 2);
this.tableLayou tPanel.Controls .Add(this.lblCi ty, 0, 3);
this.tableLayou tPanel.Controls .Add(this.lblSt ateProvince,
0, 4);
this.tableLayou tPanel.Controls .Add(this.lblPo stalCode, 0,
5);
this.tableLayou tPanel.Controls .Add(this.lblCo untry, 0, 1);
this.tableLayou tPanel.Location = new
System.Drawing. Point(0, 0);
this.tableLayou tPanel.Margin = new
System.Windows. Forms.Padding(0 , 3, 0, 3);
this.tableLayou tPanel.Name = "tableLayoutPan el";
this.tableLayou tPanel.RowCount = 6;
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( System.Windows. Forms.SizeType. Absolute,
15F));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.Size = new System.Drawing. Size(618,
165);
this.tableLayou tPanel.TabIndex = 0;
//
// txtStreet
//
this.txtStreet. Dock = System.Windows. Forms.DockStyle .Fill;
this.errorProvi der.SetIconAlig nment(this.txtS treet,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.txtStreet. Location = new System.Drawing. Point(103,
45);
this.txtStreet. MinimumSize = new System.Drawing. Size(4,
26);
this.txtStreet. Multiline = true;
this.txtStreet. Name = "txtStreet" ;
this.txtStreet. ScrollBars =
System.Windows. Forms.ScrollBar s.Vertical;
this.txtStreet. Size = new System.Drawing. Size(512, 32);
this.txtStreet. TabIndex = 1;
//
// txtCity
//
this.txtCity.Do ck = System.Windows. Forms.DockStyle .Fill;
this.errorProvi der.SetIconAlig nment(this.txtC ity,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.txtCity.Lo cation = new System.Drawing. Point(103, 83);
this.txtCity.Na me = "txtCity";
this.txtCity.Si ze = new System.Drawing. Size(512, 20);
this.txtCity.Ta bIndex = 2;
//
// ddlState
//
this.ddlState.D ock = System.Windows. Forms.DockStyle .Fill;
this.ddlState.D ropDownStyle =
System.Windows. Forms.ComboBoxS tyle.DropDownLi st;
this.ddlState.F ormattingEnable d = true;
this.errorProvi der.SetIconAlig nment(this.ddlS tate,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.ddlState.L ocation = new System.Drawing. Point(103,
109);
this.ddlState.N ame = "ddlState";
this.ddlState.S ize = new System.Drawing. Size(512, 21);
this.ddlState.T abIndex = 3;
//
// ddlCountry
//
this.ddlCountry .Dock = System.Windows. Forms.DockStyle .Fill;
this.ddlCountry .DropDownStyle =
System.Windows. Forms.ComboBoxS tyle.DropDownLi st;
this.ddlCountry .FormattingEnab led = true;
this.errorProvi der.SetIconAlig nment(this.ddlC ountry,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.ddlCountry .Location = new System.Drawing. Point(103,
18);
this.ddlCountry .Name = "ddlCountry ";
this.ddlCountry .Size = new System.Drawing. Size(512, 21);
this.ddlCountry .TabIndex = 0;
//
// txtPostalCode
//
this.txtPostalC ode.Dock =
System.Windows. Forms.DockStyle .Fill;
this.errorProvi der.SetIconAlig nment(this.txtP ostalCode,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.txtPostalC ode.Location = new System.Drawing. Point(103,
136);
this.txtPostalC ode.Name = "txtPostalCode" ;
this.txtPostalC ode.Size = new System.Drawing. Size(512, 20);
this.txtPostalC ode.TabIndex = 4;
//
// lblStreet
//
this.lblStreet. AutoSize = true;
this.lblStreet. Dock = System.Windows. Forms.DockStyle .Fill;
this.lblStreet. ImeMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblStreet. Location = new System.Drawing. Point(3, 42);
this.lblStreet. Name = "lblStreet" ;
this.lblStreet. Size = new System.Drawing. Size(94, 38);
this.lblStreet. TabIndex = 0;
this.lblStreet. Text = "lblStreet" ;
this.lblStreet. TextAlign =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// lblCity
//
this.lblCity.Au toSize = true;
this.lblCity.Do ck = System.Windows. Forms.DockStyle .Fill;
this.lblCity.Im eMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblCity.Lo cation = new System.Drawing. Point(3, 80);
this.lblCity.Na me = "lblCity";
this.lblCity.Si ze = new System.Drawing. Size(94, 26);
this.lblCity.Ta bIndex = 0;
this.lblCity.Te xt = "lblCity";
this.lblCity.Te xtAlign =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// lblStateProvinc e
//
this.lblStatePr ovince.AutoSize = true;
this.lblStatePr ovince.Dock =
System.Windows. Forms.DockStyle .Fill;
this.lblStatePr ovince.ImeMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblStatePr ovince.Location = new
System.Drawing. Point(3, 106);
this.lblStatePr ovince.Name = "lblStateProvin ce";
this.lblStatePr ovince.Size = new System.Drawing. Size(94,
27);
this.lblStatePr ovince.TabIndex = 0;
this.lblStatePr ovince.Text = "lblStateProvin ce";
this.lblStatePr ovince.TextAlig n =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// lblPostalCode
//
this.lblPostalC ode.AutoSize = true;
this.lblPostalC ode.Dock =
System.Windows. Forms.DockStyle .Fill;
this.lblPostalC ode.ImeMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblPostalC ode.Location = new System.Drawing. Point(3,
133);
this.lblPostalC ode.Name = "lblPostalCode" ;
this.lblPostalC ode.Size = new System.Drawing. Size(94, 32);
this.lblPostalC ode.TabIndex = 0;
this.lblPostalC ode.Text = "lblPostalCode" ;
this.lblPostalC ode.TextAlign =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// lblCountry
//
this.lblCountry .AutoSize = true;
this.lblCountry .Dock = System.Windows. Forms.DockStyle .Fill;
this.lblCountry .ImeMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblCountry .Location = new System.Drawing. Point(3, 15);
this.lblCountry .Name = "lblCountry ";
this.lblCountry .Size = new System.Drawing. Size(94, 27);
this.lblCountry .TabIndex = 0;
this.lblCountry .Text = "lblCountry ";
this.lblCountry .TextAlign =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// errorProvider
//
this.errorProvi der.ContainerCo ntrol = this;
//
// AddressUC
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F,
13F);
this.AutoScaleM ode =
System.Windows. Forms.AutoScale Mode.Font;
this.Controls.A dd(this.tableLa youtPanel);
this.DoubleBuff ered = true;
this.Name = "AddressUC" ;
this.Size = new System.Drawing. Size(618, 176);
this.tableLayou tPanel.ResumeLa yout(false);
this.tableLayou tPanel.PerformL ayout();

((System.Compon entModel.ISuppo rtInitialize)(t his.errorProvid er)).EndInit();
this.ResumeLayo ut(false);

}

#endregion

private System.Windows. Forms.TableLayo utPanel tableLayoutPane l;
private System.Windows. Forms.TextBox txtStreet;
private System.Windows. Forms.TextBox txtCity;
private System.Windows. Forms.ComboBox ddlState;
private System.Windows. Forms.ComboBox ddlCountry;
private System.Windows. Forms.TextBox txtPostalCode;
private System.Windows. Forms.Label lblStreet;
private System.Windows. Forms.Label lblCity;
private System.Windows. Forms.Label lblStateProvinc e;
private System.Windows. Forms.Label lblPostalCode;
private System.Windows. Forms.Label lblCountry;
private System.Windows. Forms.ErrorProv ider errorProvider;

public UserControl1()
{
InitializeCompo nent();
}
}
}

Dec 13 '06 #4
Hi Dave,

In the "real version" of my application, I use a lot of UserControl (at
least 4) with the TableLayoutPane l (at least 5)... I'll try to reduce
my use of this TableLayoutPane l... It's an interesting track to
follow... I'll try that and let you know !

Thanks !

Martin

Dave Sexton wrote:
Hi Martin,

Well this time I was able to build the solution :)

I think I see the flicker you're referring to, but it's awfully fast on my
computer. TableLayoutPane l is usually the problem, although it still
renders quickly for such a small control.

It sounds to me like it might be your data-access code that is the bottle
neck (you mentioned it in another post in this thread). If so you might
want to use asynchronous calls to the database or use a BackgroundWorke r
component to free up the UI thread while it's loading.

Actually, a better question would be, how much flicker is there? What
exactly do you mean by "appear one after one"? Is it painfully obvious or
is it so quick that it's easy to miss (as in my testing)?

To be perfectly honest, if it's really fast then I don't think that there's
anything you can do about it. That's the price you pay when using Controls
to ease development.

--
Dave Sexton

"Martin" <ma*********@gm ail.comwrote in message
news:11******** **************@ j72g2000cwa.goo glegroups.com.. .
Hi everyone !

For those who haven't read my previous post, I have a problem with a
UserControl. When I try to display it on a form, controls seem to
appear one after one. In the following example, it's less visible
because controls don't execute any code... Is someone has an idea of
how I could solve this problem and also improve the method
ShowUserControl . I try to figure out I could flicker effect when I
press the button twice quickly.

Thanks for your help !

----- Form1.cs -----
using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;

namespace WindowsApplicat ion2
{
public class Form1 : Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.splitConta iner1 = new
System.Windows. Forms.SplitCont ainer();
this.button1 = new System.Windows. Forms.Button();
this.splitConta iner1.Panel2.Su spendLayout();
this.splitConta iner1.SuspendLa yout();
this.SuspendLay out();
//
// splitContainer1
//
this.splitConta iner1.Dock =
System.Windows. Forms.DockStyle .Fill;
this.splitConta iner1.Location = new System.Drawing. Point(0,
0);
this.splitConta iner1.Name = "splitContainer 1";
//
// splitContainer1 .Panel2
//
this.splitConta iner1.Panel2.Co ntrols.Add(this .button1);
this.splitConta iner1.Size = new System.Drawing. Size(642,
305);
this.splitConta iner1.SplitterD istance = 425;
this.splitConta iner1.TabIndex = 0;
//
// button1
//
this.button1.Lo cation = new System.Drawing. Point(21, 22);
this.button1.Na me = "button1";
this.button1.Si ze = new System.Drawing. Size(75, 23);
this.button1.Ta bIndex = 0;
this.button1.Te xt = "button1";
this.button1.Us eVisualStyleBac kColor = true;
this.button1.Cl ick += new
System.EventHan dler(this.butto n1_Click);
//
// Form1
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F,
13F);
this.AutoScaleM ode =
System.Windows. Forms.AutoScale Mode.Font;
this.ClientSize = new System.Drawing. Size(642, 305);
this.Controls.A dd(this.splitCo ntainer1);
this.Name = "Form1";
this.Text = "Form1";
this.splitConta iner1.Panel2.Re sumeLayout(fals e);
this.splitConta iner1.ResumeLay out(false);
this.ResumeLayo ut(false);

}

#endregion

private System.Windows. Forms.SplitCont ainer splitContainer1 ;
private System.Windows. Forms.Button button1;
public Form1()
{
InitializeCompo nent();
}

private void ShowUserControl (UserControl _objUserControl ,
Control _objContainer)
{
_objUserControl .Location = new Point(0, 0);
_objUserControl .Size =
new Size(_objContai ner.Width, _objContainer.H eight);
_objUserControl .Anchor = AnchorStyles.To p |
AnchorStyles.Bo ttom |
AnchorStyles.Le ft |
AnchorStyles.Ri ght;

_objContainer.S uspendLayout();

_objContainer.C ontrols.Clear() ;
_objContainer.C ontrols.Add(_ob jUserControl);

_objContainer.R esumeLayout();
}

private void button1_Click(o bject sender, EventArgs e)
{
ShowUserControl (new UserControl1(),
splitContainer1 .Panel1);
}
}
}

---- UserControl1.cs ----
using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows. Forms;

namespace WindowsApplicat ion2
{
public class UserControl1 : UserControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#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 InitializeCompo nent()
{
this.components = new System.Componen tModel.Containe r();
this.tableLayou tPanel = new
System.Windows. Forms.TableLayo utPanel();
this.txtStreet = new System.Windows. Forms.TextBox() ;
this.txtCity = new System.Windows. Forms.TextBox() ;
this.ddlState = new System.Windows. Forms.ComboBox( );
this.ddlCountry = new System.Windows. Forms.ComboBox( );
this.txtPostalC ode = new System.Windows. Forms.TextBox() ;
this.lblStreet = new System.Windows. Forms.Label();
this.lblCity = new System.Windows. Forms.Label();
this.lblStatePr ovince = new System.Windows. Forms.Label();
this.lblPostalC ode = new System.Windows. Forms.Label();
this.lblCountry = new System.Windows. Forms.Label();
this.errorProvi der = new
System.Windows. Forms.ErrorProv ider(this.compo nents);
this.tableLayou tPanel.SuspendL ayout();

((System.Compon entModel.ISuppo rtInitialize)(t his.errorProvid er)).BeginInit( );
this.SuspendLay out();
//
// tableLayoutPane l1
//
this.tableLayou tPanel.Anchor =
((System.Window s.Forms.AnchorS tyles)(((System .Windows.Forms. AnchorStyles.To p
| System.Windows. Forms.AnchorSty les.Left)
| System.Windows. Forms.AnchorSty les.Right)));
this.tableLayou tPanel.ColumnCo unt = 2;
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Absolute,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.ColumnSt yles.Add(new
System.Windows. Forms.ColumnSty le(System.Windo ws.Forms.SizeTy pe.Percent,
100F));
this.tableLayou tPanel.Controls .Add(this.txtSt reet, 1, 2);
this.tableLayou tPanel.Controls .Add(this.txtCi ty, 1, 3);
this.tableLayou tPanel.Controls .Add(this.ddlSt ate, 1, 4);
this.tableLayou tPanel.Controls .Add(this.ddlCo untry, 1, 1);
this.tableLayou tPanel.Controls .Add(this.txtPo stalCode, 1,
5);
this.tableLayou tPanel.Controls .Add(this.lblSt reet, 0, 2);
this.tableLayou tPanel.Controls .Add(this.lblCi ty, 0, 3);
this.tableLayou tPanel.Controls .Add(this.lblSt ateProvince,
0, 4);
this.tableLayou tPanel.Controls .Add(this.lblPo stalCode, 0,
5);
this.tableLayou tPanel.Controls .Add(this.lblCo untry, 0, 1);
this.tableLayou tPanel.Location = new
System.Drawing. Point(0, 0);
this.tableLayou tPanel.Margin = new
System.Windows. Forms.Padding(0 , 3, 0, 3);
this.tableLayou tPanel.Name = "tableLayoutPan el";
this.tableLayou tPanel.RowCount = 6;
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( System.Windows. Forms.SizeType. Absolute,
15F));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.RowStyle s.Add(new
System.Windows. Forms.RowStyle( ));
this.tableLayou tPanel.Size = new System.Drawing. Size(618,
165);
this.tableLayou tPanel.TabIndex = 0;
//
// txtStreet
//
this.txtStreet. Dock = System.Windows. Forms.DockStyle .Fill;
this.errorProvi der.SetIconAlig nment(this.txtS treet,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.txtStreet. Location = new System.Drawing. Point(103,
45);
this.txtStreet. MinimumSize = new System.Drawing. Size(4,
26);
this.txtStreet. Multiline = true;
this.txtStreet. Name = "txtStreet" ;
this.txtStreet. ScrollBars =
System.Windows. Forms.ScrollBar s.Vertical;
this.txtStreet. Size = new System.Drawing. Size(512, 32);
this.txtStreet. TabIndex = 1;
//
// txtCity
//
this.txtCity.Do ck = System.Windows. Forms.DockStyle .Fill;
this.errorProvi der.SetIconAlig nment(this.txtC ity,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.txtCity.Lo cation = new System.Drawing. Point(103, 83);
this.txtCity.Na me = "txtCity";
this.txtCity.Si ze = new System.Drawing. Size(512, 20);
this.txtCity.Ta bIndex = 2;
//
// ddlState
//
this.ddlState.D ock = System.Windows. Forms.DockStyle .Fill;
this.ddlState.D ropDownStyle =
System.Windows. Forms.ComboBoxS tyle.DropDownLi st;
this.ddlState.F ormattingEnable d = true;
this.errorProvi der.SetIconAlig nment(this.ddlS tate,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.ddlState.L ocation = new System.Drawing. Point(103,
109);
this.ddlState.N ame = "ddlState";
this.ddlState.S ize = new System.Drawing. Size(512, 21);
this.ddlState.T abIndex = 3;
//
// ddlCountry
//
this.ddlCountry .Dock = System.Windows. Forms.DockStyle .Fill;
this.ddlCountry .DropDownStyle =
System.Windows. Forms.ComboBoxS tyle.DropDownLi st;
this.ddlCountry .FormattingEnab led = true;
this.errorProvi der.SetIconAlig nment(this.ddlC ountry,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.ddlCountry .Location = new System.Drawing. Point(103,
18);
this.ddlCountry .Name = "ddlCountry ";
this.ddlCountry .Size = new System.Drawing. Size(512, 21);
this.ddlCountry .TabIndex = 0;
//
// txtPostalCode
//
this.txtPostalC ode.Dock =
System.Windows. Forms.DockStyle .Fill;
this.errorProvi der.SetIconAlig nment(this.txtP ostalCode,
System.Windows. Forms.ErrorIcon Alignment.Middl eLeft);
this.txtPostalC ode.Location = new System.Drawing. Point(103,
136);
this.txtPostalC ode.Name = "txtPostalCode" ;
this.txtPostalC ode.Size = new System.Drawing. Size(512, 20);
this.txtPostalC ode.TabIndex = 4;
//
// lblStreet
//
this.lblStreet. AutoSize = true;
this.lblStreet. Dock = System.Windows. Forms.DockStyle .Fill;
this.lblStreet. ImeMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblStreet. Location = new System.Drawing. Point(3, 42);
this.lblStreet. Name = "lblStreet" ;
this.lblStreet. Size = new System.Drawing. Size(94, 38);
this.lblStreet. TabIndex = 0;
this.lblStreet. Text = "lblStreet" ;
this.lblStreet. TextAlign =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// lblCity
//
this.lblCity.Au toSize = true;
this.lblCity.Do ck = System.Windows. Forms.DockStyle .Fill;
this.lblCity.Im eMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblCity.Lo cation = new System.Drawing. Point(3, 80);
this.lblCity.Na me = "lblCity";
this.lblCity.Si ze = new System.Drawing. Size(94, 26);
this.lblCity.Ta bIndex = 0;
this.lblCity.Te xt = "lblCity";
this.lblCity.Te xtAlign =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// lblStateProvinc e
//
this.lblStatePr ovince.AutoSize = true;
this.lblStatePr ovince.Dock =
System.Windows. Forms.DockStyle .Fill;
this.lblStatePr ovince.ImeMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblStatePr ovince.Location = new
System.Drawing. Point(3, 106);
this.lblStatePr ovince.Name = "lblStateProvin ce";
this.lblStatePr ovince.Size = new System.Drawing. Size(94,
27);
this.lblStatePr ovince.TabIndex = 0;
this.lblStatePr ovince.Text = "lblStateProvin ce";
this.lblStatePr ovince.TextAlig n =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// lblPostalCode
//
this.lblPostalC ode.AutoSize = true;
this.lblPostalC ode.Dock =
System.Windows. Forms.DockStyle .Fill;
this.lblPostalC ode.ImeMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblPostalC ode.Location = new System.Drawing. Point(3,
133);
this.lblPostalC ode.Name = "lblPostalCode" ;
this.lblPostalC ode.Size = new System.Drawing. Size(94, 32);
this.lblPostalC ode.TabIndex = 0;
this.lblPostalC ode.Text = "lblPostalCode" ;
this.lblPostalC ode.TextAlign =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// lblCountry
//
this.lblCountry .AutoSize = true;
this.lblCountry .Dock = System.Windows. Forms.DockStyle .Fill;
this.lblCountry .ImeMode =
System.Windows. Forms.ImeMode.N oControl;
this.lblCountry .Location = new System.Drawing. Point(3, 15);
this.lblCountry .Name = "lblCountry ";
this.lblCountry .Size = new System.Drawing. Size(94, 27);
this.lblCountry .TabIndex = 0;
this.lblCountry .Text = "lblCountry ";
this.lblCountry .TextAlign =
System.Drawing. ContentAlignmen t.MiddleLeft;
//
// errorProvider
//
this.errorProvi der.ContainerCo ntrol = this;
//
// AddressUC
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F,
13F);
this.AutoScaleM ode =
System.Windows. Forms.AutoScale Mode.Font;
this.Controls.A dd(this.tableLa youtPanel);
this.DoubleBuff ered = true;
this.Name = "AddressUC" ;
this.Size = new System.Drawing. Size(618, 176);
this.tableLayou tPanel.ResumeLa yout(false);
this.tableLayou tPanel.PerformL ayout();

((System.Compon entModel.ISuppo rtInitialize)(t his.errorProvid er)).EndInit();
this.ResumeLayo ut(false);

}

#endregion

private System.Windows. Forms.TableLayo utPanel tableLayoutPane l;
private System.Windows. Forms.TextBox txtStreet;
private System.Windows. Forms.TextBox txtCity;
private System.Windows. Forms.ComboBox ddlState;
private System.Windows. Forms.ComboBox ddlCountry;
private System.Windows. Forms.TextBox txtPostalCode;
private System.Windows. Forms.Label lblStreet;
private System.Windows. Forms.Label lblCity;
private System.Windows. Forms.Label lblStateProvinc e;
private System.Windows. Forms.Label lblPostalCode;
private System.Windows. Forms.Label lblCountry;
private System.Windows. Forms.ErrorProv ider errorProvider;

public UserControl1()
{
InitializeCompo nent();
}
}
}
Dec 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7114
by: Dave Veeneman | last post by:
Is there a simple way to pass drag-and-drop events to a child control in a UserControl? Here's an example: I have created a UserControl which contains a treeview and some text boxes. I want to be able to drag-and-drop to the treeview from outside the UserControl. Now, when I drag over the treeview in the UserControl, the UserControl gets the drag-and-drop events, but the treeview doesn't. Is there a simple way to pass drag-and-drop...
8
1955
by: Raed Sawalha | last post by:
Hi, I have a strange problem with a usercontrol on a page. The usercontrol dispalyes three categories (From a database) when the user clicks a category they see all the products in a shop for that category, the results are paged 10 to a page and the user can page them. As this "Category" usercontrol hardly ever changes I wanted to setup up caching for it. However I realised that when the user clicks a ctageory it is selected and...
2
4622
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation for me! I apologize for the length of this posting, but I wanted to make sure that I get an answer other than "Hey man, just use LoadControl!", because this is not what I want. The Task: Isolate a collection of web forms which are created as
41
4283
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based on some initialization information obtained elsewhere. Basically, I'm going to create my own dynamic toolbar where the toolbarbuttons can change. I'm not using the VB toolbar because of limitations in changing things like backcolor (I can't get...
12
2193
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control server. It "serves" back the required control (either WebControl or UserControl) based on the contents of an xml file. The code in the webform places each control in a TableCell. My problem is that the control server works as far as returning the...
9
14433
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it does not. The problem is that the webcontrols get created on the OnLoad event of the usercontrol and the event handlers are assigned at the same time. I have to click twice on the controls for the events to be raised, the first time nothing...
6
12128
by: MeowCow | last post by:
I have created a UserControl that encapsulates a third party data grid. My goal was to create my own DataSource and DataMember properties that forward the binding to the third party grid, then use binding like normal. The problem I am running into is that my UserControl ends up with a different BindingContext then the ParentForm it is contained in and thus all other controls on the parent form. (I want various controls on the form to...
10
2411
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's my question. Once the UserControl is dropped onto the container page, how can I perform some action on the codebehind of the container page from the codebehind of the UserControl? For instance, suppose that the UserControl is dropped inside one...
3
2020
by: Martin | last post by:
Hi ! I've developed a small UserControl with five textbox and label. However, when I want to display the UserControl in a form, controls appear slowly one after one. I've activated double buffering and removed all code in the OnLoad, constructor and I still have the same problem. Here is the code that I use to display the UserControl un the form _objContainer.SuspendLayout();
0
8053
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8557
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8205
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8380
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5504
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2519
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.