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

Vertical Alignment?

6 Answers 3352 Views
TextBoxControl
This is a migrated thread and some comments may be shown as answers.
Damien
Top achievements
Rank 1
Damien asked on 22 Dec 2017, 09:52 PM

I was wondering how I can vertically align the text input in the center? I can horizontally align, but my text still appears at the top of the TextBoxControl and I want it vertically centered.

 

Thanks.

6 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 25 Dec 2017, 07:44 AM
Hi Damien,

There is no property that controls this but you can set the Margin of the view:
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    var topMargin = (radTextBoxControl1.TextBoxElement.ViewElement.Size.Height / 2) - (radTextBoxControl1.TextBoxElement.ViewElement.Children[0].Size.Height / 2);
    radTextBoxControl1.TextBoxElement.ViewElement.Margin = new Padding(0, topMargin, 0, 0);
}

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Damien
Top achievements
Rank 1
answered on 26 Dec 2017, 03:11 AM

Hi Dimitar

So when do I actually call this function?

thanks.

0
Damien
Top achievements
Rank 1
answered on 26 Dec 2017, 03:19 AM

Will this also affect the NullText to display in the vertical middle? If not, is there a way of doing that too?

Is this a likely feature that will be included in the future, as I have many TextBoxControl controls in my application, and having to add this extra code for all of this is tedious?

Thanks.

0
Dimitar
Telerik team
answered on 26 Dec 2017, 09:22 AM
Hi Damien,

To center the null text you need to set the Margin of the following element as well:
radTextBoxControl1.TextBoxElement.Children[1].Children[0].Margin = new Padding(0, topMargin, 0, 0);

This code should be called when the form layout is loaded or when the textbox is resized. 

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Damien
Top achievements
Rank 1
answered on 28 Dec 2017, 12:12 PM

thanks, all sorted.

 

Is this a likely feature that is coming or can it be?

 

thanks.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 Dec 2017, 01:25 PM
Hello, Damien, 

Thank you for writing back. 

By design, vertical alignment for RadTextBoxControl is not supposed to be supported. It is an input control and the text is purposed to be shown from top to bottom in a multiline text box. The standard MS TextBox also supports only horizontal text alignment. Currently, we don't have plans to change this behavior. If other customers have a similar request we will consider it in future.

I hope this information helps. If you have any additional questions, please let me know. 

 Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
TextBoxControl
Asked by
Damien
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Damien
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or