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

TextBoxControl Text Alignment

8 Answers 873 Views
TextBoxControl
This is a migrated thread and some comments may be shown as answers.
Claire
Top achievements
Rank 1
Claire asked on 18 Mar 2013, 12:07 AM
How can I expose and set the text alignment property of a TextBoxControl? I need to use a RadTextBoxControl for theming so using RadTextBox is not an option. I cannot find a way to set the text alignment (HorizontalAlignment of left/right/center not ContentAlignment).

8 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 18 Mar 2013, 01:01 PM
Hi Claire,

Thank you for writing.

Currently, RadTextBoxControl does not support text alignment. A feature request for such is already available in our Public Issue Tracking System. Feel free to add your vote for it here: http://www.telerik.com/support/pits.aspx#/details/Issue=14000. The more votes an item receives the higher it gets in our priority list.

I hope that you find this information useful.
 

All the best,
Stefan
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
Brendan
Top achievements
Rank 1
answered on 28 Jan 2015, 10:58 PM
On the subject of textbox formatting, I want to allow users to hide or show the textbox background, therefore I have used the RadTextBoxControl.  I also let users choose themes.  The problem I am having is that I cannot figure out how to keep a label and RTBC aligned vertically throughout various themes.

The attached image shows what I mean.  I have set the label and RTBC to the same height.  I have aligned the control tops.  The left side of the image shows the opacity set to 0 to hide the border and the background, the right side is default.  On themes like Windows8 (bottom image) the alignment does not work anymore and the text is 'below' the label. 

How can I overcome this?  It is somewhat a deal breaker.  OTOH the RadTextBox alignment works fine across themes but the background cannot be made transparent/hidden as far as I can tell.

Thanks for the help.
0
Dimitar
Telerik team
answered on 02 Feb 2015, 02:38 PM
Hello Brendan,

Thank you for writing.

Please note that the different themes are using different margin and padding. In this particular case the Windows 8 theme has 1 pixel top margin and this is why the items are not aligned - when the theme is changed the margin is changed as well. To keep the items aligned you can set the Margin property in code:
radTextBoxControl1.TextBoxElement.ViewElement.Margin = new Padding(0);

We will also consider this case when we are working on editors improvements.

In addition the different themes are using different setting for colors and borders. For this case the easier approach will be to set the required properties explicitly in code:
radTextBoxControl1.TextBoxElement.BorderBoxStyle = BorderBoxStyle.SingleBorder;
radTextBoxControl1.TextBoxElement.BorderColor = Color.Transparent;
radTextBoxControl1.TextBoxElement.BackColor = Color.Transparent;

You can use the RadControlSpy tool to determine which properties are changed by the themes and set them in code (changing the theme would not affect a property which is set in code). 

Please let me know if there is something else I can help you with. 
 
Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Brendan
Top achievements
Rank 1
answered on 02 Feb 2015, 02:43 PM
Thanks Dimitar.  I since found the padding issue and submitted a support ticket.  If padding has to be changed for every RTBC in a project each time a theme is changed then the affected themes need to be fixed.  Otherwise project level theming cannot be implemented. 
0
Dimitar
Telerik team
answered on 03 Feb 2015, 11:50 AM
Hi Brendan,

Thank you for writing back.

You do not need to change the padding each time when the theme is changed. Setting properties in code (local value) has higher priority than setting properties in the theme (see here for more information). So you need to change the margin only once when the application is initialized. For example if you initialize the text box control like this you do not need to do anything when the theme is changed (you can easily iterate through the controls in the form):
Public Sub New()
    InitializeComponent()
    radLabel1.Text = "STONE"
    radTextBoxControl1.Text = "STONE"
    radTextBoxControl1.TextBoxElement.BorderBoxStyle = BorderBoxStyle.SingleBorder
    radTextBoxControl1.TextBoxElement.BorderColor = Color.Transparent
    radTextBoxControl1.TextBoxElement.BackColor = Color.Transparent
 
    radTextBoxControl1.TextBoxElement.ViewElement.Margin = New Padding(0)
End Sub

Of course you can change the properties in the themes if you prefer to. 

I hope this information helps.

Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Brendan
Top achievements
Rank 1
answered on 03 Feb 2015, 05:45 PM
Thanks Dimitar.  Setting it up in the initialization makes things much easier.
0
Brendan
Top achievements
Rank 1
answered on 06 Mar 2015, 04:12 PM
Hi Dimitar.  I need to set a transparent background for RadMaskedEditBoxes on the same form as the RadTextBoxes.  I tried to set various elements to transparent in code and via the Control spy and have not had much luck.

Is there a way to set the background of an RMEB to transparent?

Thanks.
0
Dimitar
Telerik team
answered on 11 Mar 2015, 09:00 AM
Hi Brendan,

Thank you for writing back.

RadMaskedEditBox is using the default .NET textbox inside it. The .NET text box cannot have transparent background and this is why setting the BackColor of the control elements does not have any effect. In this case what you can do is replace the text box with one that supports transparent background. I have attached a small project which shows that.

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
TextBoxControl
Asked by
Claire
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Brendan
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or