This is a migrated thread and some comments may be shown as answers.

Inheriting RadTextbox with Multiline problems

1 Answer 67 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
superold
Top achievements
Rank 1
superold asked on 30 Jan 2009, 08:38 AM
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

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 02 Feb 2009, 03:23 PM
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.
Tags
TextBox
Asked by
superold
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or