1. Welcome Guest! In order to create a new topic or reply to an existing one, you must register first. It is easy and free. Click here to sign up now!.
    Dismiss Notice

Avoid constructor initialization to Designer

Discussion in 'Microsoft News' started by NewsBot, Apr 9, 2008.

  1. NewsBot

    NewsBot I Got News

    Joined:
    Feb 8, 2006
    Messages:
    1,813
    Operating System:
    Windows Vista Home Premium
    Hi!,

    I've created a new component, in constructor i set default properties
    (Nothing in special)

    <!--sizeo:2--><span style="font-size:10pt;line-height:100% <!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff <!--/coloro-->******* public LookUpCentroContable() : base()
    ******* {***********
    ***********
    *********** Properties.Columns.Add(new LookUpColumnInfo("IdCentro", 70, "Id."));
    *********** Properties.Columns["IdCentro"].FormatType = Numeric;
    *********** Properties.Columns.Add(new LookUpColumnInfo("Nombre", 250, "Nombre"));
    *********** Properties.Columns.Add(new LookUpColumnInfo("CentroAbrev", 90, "Abreviatura"));
    *********** Properties.PopupWidth = 410;
    *********** Properties.NullText = "";
    ******* }<!--colorc--><!--/colorc-->

    But when i drop this control on a form myForm.Designer.cs creates these lines automatically :-(

    *********** //
    *********** // lookUpCentroContable
    *********** //
    *********** this.lookUpCentroContable.Location = new System.Drawing.Point(128, 0);
    *********** this.lookUpCentroContable.Name = "lookUpCentroContable";
    *********** this.lookUpCentroContable.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
    *********** new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
    *********** this.lookUpCentroContable.Properties.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] {
    *********** new DevExpress.XtraEditors.Controls.LookUpColumnInfo("IdCentro", "Id.", 70, DevExpress.Utils.FormatType.Numeric, "", true, DevExpress.Utils.HorzAlignment.Default, DevExpress.Data.ColumnSortOrder.None),
    *********** new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Nombre", "Nombre", 250),
    *********** new DevExpress.XtraEditors.Controls.LookUpColumnInfo("CentroAbrev", "Abreviatura", 90)});
    *********** this.lookUpCentroContable.Properties.NullText = "";
    *********** this.lookUpCentroContable.Properties.PopupWidth = 410;
    *********** this.lookUpCentroContable.Size = new System.Drawing.Size(100, 20);
    *********** this.lookUpCentroContable.TabIndex = 39;

    And the result is these columns are setting twice, so it appears twice in execution :-(

    How can I avoid these designer automatic initializations.
    I supose i should move code from constructor to an override method based on Control, any idea?

    Thanks in advance
    <!--sizec--><!--/sizec-->



     

Share This Page