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

RibbonBar with RadTextBoxElement - multiline problem

5 Answers 124 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Michał K
Top achievements
Rank 1
Michał K asked on 19 Aug 2009, 09:13 PM
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.


5 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 20 Aug 2009, 07:04 AM
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.
0
Michał K
Top achievements
Rank 1
answered on 20 Aug 2009, 10:16 AM
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 ?


0
Accepted
Peter
Telerik team
answered on 20 Aug 2009, 11:27 AM
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.
0
Michał K
Top achievements
Rank 1
answered on 20 Aug 2009, 12:29 PM
I was thinking to that this way, but I want to know is there any other option.

It's working, thanks ;)
0
Peter
Telerik team
answered on 21 Aug 2009, 07:52 AM
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.
Tags
RibbonBar
Asked by
Michał K
Top achievements
Rank 1
Answers by
Peter
Telerik team
Michał K
Top achievements
Rank 1
Share this question
or