Inheriting RadTextbox with Multiline problems

2 posts, 0 answers
  1. Jorge Delgado-Lopez
    Jorge Delgado-Lopez avatar
    82 posts
    Member since:
    Aug 2007

    Posted 30 Jan 2009 Link to this post

    Hi,

    I am upgrading from an old solution, see http://www.telerik.com/community/forums/winforms/ui-controls/labelmultilinetextbox-with-validation.aspx, since this version is missing some functionality which I now need.

    My class inherits from RadTextBox where I override CreateChildItems and create my own.

    I follow the logic from your source and it all works perfectly. Except the multiline property, how can I implement it?

    I use the following controls.
            private readonly RadTextBoxItem textBox = new RadTextBoxItem();
            private readonly TextPrimitive title = new TextPrimitive();
            private readonly TextPrimitive validation = new TextPrimitive();

    A cut down version of CreateChildItems

                BoxLayout layoutTexts = new BoxLayout();
                layoutTexts.Orientation = Orientation.Horizontal;
                layoutTexts.StretchVertically = false;  // when true the control is drawn differently

                layoutTexts.Children.Add(title);
                layoutTexts.Children.Add(validation);

                BoxLayout layout = new BoxLayout();
                layout.Orientation = Orientation.Vertical;

                layout.Children.Add(layoutTexts);

                base.InitializeTextElement();

                layout.Children.Add(textBoxElement);

                RootElement.Children.Add(layout);

                Size = new Size(425, 34); // default size

    Thanks
    - jorge
  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 02 Feb 2009 Link to this post

    Hi Jorge Delgado-Lopez,

    Thank for writing.

    You should set the Control's AutoSize property to false
      public LabelMultilineTextBox() 
      { 
           this.AutoSize = false

    Also, override InitializeRootElement and set the RootElement's Stretch Property to True
     protected override void InitializeRootElement(RootRadElement rootElement) 
     { 
           base.InitializeRootElement(rootElement); 
           rootElement.StretchVertically = true;            
     } 

    Please refer the attached project.

    Greetings,
    Peter
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top