TextBoxControl Text Alignment

9 posts, 0 answers
  1. Claire
    Claire avatar
    1 posts
    Member since:
    Nov 2012

    Posted 17 Mar 2013 Link to this post

    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).
  2. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 18 Mar 2013 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Brendan
    Brendan avatar
    52 posts
    Member since:
    Dec 2011

    Posted 28 Jan 2015 in reply to Stefan Link to this post

    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.
  5. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 02 Feb 2015 Link to this post

    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.

     
  6. Brendan
    Brendan avatar
    52 posts
    Member since:
    Dec 2011

    Posted 02 Feb 2015 in reply to Dimitar Link to this post

    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. 
  7. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 03 Feb 2015 Link to this post

    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.

     
  8. Brendan
    Brendan avatar
    52 posts
    Member since:
    Dec 2011

    Posted 03 Feb 2015 in reply to Dimitar Link to this post

    Thanks Dimitar.  Setting it up in the initialization makes things much easier.
  9. Brendan
    Brendan avatar
    52 posts
    Member since:
    Dec 2011

    Posted 06 Mar 2015 in reply to Dimitar Link to this post

    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.
  10. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 11 Mar 2015 Link to this post

    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.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready