WinForms problem...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jacek Jurkowski

    WinForms problem...

    I wrote my own WinForm controls inherited from
    standard controls f.e. formatted TextBox etc...
    All worked perfectly with Vs.net 2002 but when i
    add my controls to a form visually with 2003 version
    it's bahaviour is strange. F.e. I add my simple label control
    to a form tab control. It looks ok but when i'm running the project
    it disapperas. In the windows forms generated code i see
    that this control wasn't addes to a tab control really. There is no
    this.tabControl 0.Controls.Add( this.label0);
    Control itself have no text property even if i set this before. There is no
    this.label0.Tex t = "My text";
    And the control size isn't set. There is some bug in WinForms generator?
    Or I'm doing something wrong?

    My control's code:

    using System;
    using System.Drawing;
    using System.Collecti ons;
    using System.Diagnost ics;
    using System.Windows. Forms;
    using System.Componen tModel;
    namespace Datacomp.Dataco mpControls
    {
    /// <summary>
    /// DatacompLabel [Jacek 2002-11-19]
    /// </summary>
    public class DatacompLabel : System.Windows. Forms.Label
    {
    #region Members
    private System.Windows. Forms.ToolTip toolTip1;
    private System.Componen tModel.IContain er components;
    #endregion

    #region Constructors [Jacek 2002-10-20]
    /// <summary>
    /// Konstruktor komponentu.
    /// </summary>
    public DatacompLabel()
    {
    InitializeCompo nent();
    }
    /// <summary>

    /// Konstruktor komponentu.
    /// </summary>
    /// <param name="container ">Kontener rodzicielski.</param>
    public DatacompLabel(S ystem.Component Model.IContaine r container)
    {
    container.Add(t his);
    InitializeCompo nent();
    }
    #endregion

    #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.toolTip1 = new
    System.Windows. Forms.ToolTip(t his.components) ;
    //
    // DatacompLabel
    //
    this.AutoSize = true;
    this.FlatStyle = System.Windows. Forms.FlatStyle .System;
    this.Size = new System.Drawing. Size(0, 13);
    }
    #endregion

    #region Propertys implementation [Jacek 2002-10-24]
    /// <summary>
    /// Czy automatyczne dopasowanie rozmiaru?
    /// </summary>
    [DefaultValue(tr ue)]
    public override bool AutoSize
    {
    get{return base.AutoSize;}
    set{base.AutoSi ze = value;}
    }
    /// <summary>
    /// Rodzaj sp³aszczenia.
    /// </summary>
    [DefaultValue(Sy stem.Windows.Fo rms.FlatStyle.S ystem)]
    public new System.Windows. Forms.FlatStyle FlatStyle
    {
    get{return base.FlatStyle; }
    set{base.FlatSt yle = value;}
    }
    #endregion
    }
    }


Working...