RibbonBar with RadTextBoxElement - multiline problem

6 posts, 1 answers
  1. Michał K
    Michał K avatar
    6 posts
    Member since:
    Aug 2009

    Posted 19 Aug 2009 Link to this post

    Hi everyone!

    I need to add a multiline TextBox to the RibbonBar. I used that code in the desingercode (short version ;) )

    private InitializeComponent() 
    //(...) 
    this.radTextBoxElement = new RadTextBoxElement(); 
     
    //(...) 
    // radRibbonBarGroupMessageText 
    //  
    this.radRibbonBarGroupMessageText.Items.AddRange(new Telerik.WinControls.RadItem[] {this.radTextBoxElement}); 
    this.radRibbonBarGroupMessageText.Name = "radRibbonBarGroupMessageText"
    this.radRibbonBarGroupMessageText.Orientation = System.Windows.Forms.Orientation.Horizontal; 
    this.radRibbonBarGroupMessageText.Text = "Treść"
    // 
    //(...) 
    // 
     
    RadTextBoxElement radTextBoxElement; 

    then, using the designer I heve set the properties of this TextBoxElement.TextBoxItem : multiline to true, and the null text to proper info and AcceptReturn = true;

    When I run my application, I see the null text, but I can start a new line with enter key and even when I put a lot of text (reach right edge) text doesn,t break to new line... Can someone help me fix that? I will be greatfull.


  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 20 Aug 2009 Link to this post

    Hi Michał K,

    Thank you for contacting us. I looked at your code and I think it is OK. Please, try to set Multiline to true for the TextBoxItem too. Please refer to the sample code below:


    radTextBoxElement.TextBoxItem.Multiline=true

    I hope this helps.

    Sincerely yours,
    Peter
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Michał K
    Michał K avatar
    6 posts
    Member since:
    Aug 2009

    Posted 20 Aug 2009 Link to this post

    Unfortunately it doesn't work. I tried to do that on 4 ways:

    1. Set all this options in Designer - doesn't work
    2. Add these line of code in designer.cs:

    this.radTextBoxElement.RadTextBoxItem.Multiline = true
    this.radTextBoxElement.RadTextBoxItem.AcceptsReturn = true
    this.radTextBoxElement.RadTextBoxItem.ScrollBars = scrollbars.vertical; 
     

    3. Or this designer-like lines:

    ((Telerik.WinControls.UI.RadTextBoxItem)(this.radTextBoxElement.GetChildAt(0))).NullText = "<< podaj treść >>"
    ((Telerik.WinControls.UI.RadTextBoxItem)(this.radTextBoxElement.GetChildAt(0))).StretchVertically = true
    ((Telerik.WinControls.UI.RadTextBoxItem)(this.radTextBoxElement.GetChildAt(0))).Multiline = true
    ((Telerik.WinControls.UI.RadTextBoxItem)(this.radTextBoxElement.GetChildAt(0))).AcceptsReturn = true
    ((Telerik.WinControls.UI.RadTextBoxItem)(this.radTextBoxElement.GetChildAt(0))).ScrollBars = scrollbars.vertical; 

    But when I try it that way (methods 2 and 3) everything works till I open the designer window. When I do that Visual delete these lines of code, even that, these option are set to true in Properties Window...

    So I think maybe I should add the variable RadTextBoxItem to my code? In short version:

    private void InitializeComponent() 
    //(...) 
    this.RadTextBoxItem1 = new RadTextBoxItem(); 
    this.RadTextBoxElement1 = new RadTextBoxElement(this.RadTextBoxItem); 
     
    //(..) 

    And then I set these values from designer properties window - and it seems that this time it works. But in designer now I can select separately both element (I can select TextBoxElement and inside of it I can select the TextBoxItem). Values in code in TextBoxItem properties are set to true... but it doesn't work anyway :/

    Any suggestions? I can past or sent all code if it needed.

    Maybe I need to put that code in the *.cs file, not *.designer.cs ?


  5. Answer
    Peter
    Admin
    Peter avatar
    1148 posts

    Posted 20 Aug 2009 Link to this post

    Hello Michał K,

    I reproduced the issue. Please, add these lines of code after calling InitializeComponent:

    this.radTextBoxElement.StretchVertically = true
    radTextBoxElement.TextBoxItem.Multiline = true
    radTextBoxElement.TextBoxItem.AcceptsReturn = true

    Alse, please refer to the attached project. Don't hesitate to contact us if you have other questions.

    Best wishes,
    Peter
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  6. Michał K
    Michał K avatar
    6 posts
    Member since:
    Aug 2009

    Posted 20 Aug 2009 Link to this post

    I was thinking to that this way, but I want to know is there any other option.

    It's working, thanks ;)
  7. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 21 Aug 2009 Link to this post

    Hello Michał K,

    RadTextBox (respectively RadTextBoxElement) control uses internally the standard TextBox control (mainly due to its complexity). This means that RadTextBoxElement has the same limitations TextBox has. You can control whether the text box should have single or multiple lines by settings the Multiline property (radTextBoxElement.TextBoxItem.Multiline).

    Greetings,
    Peter
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
Back to Top
UI for WinForms is Visual Studio 2017 Ready