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

Control Alignement in LayoutControlItem

1 Answer 105 Views
LayoutControl
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 28 Aug 2018, 05:17 PM

Hi everybody :)

I am turning a little bit crazy, I am trying building a classic form, with some radlabel and some radtextbox control.

All controls are placed in LayoutControlItems, and for elementary aesthetic reason I would like that my label control would be align middle right in the LayoutControlItem. to be close to the radTextBox.

For some reason beyond my understanding, whatever the way I have been using, moving anchor, TextAlignment, my radlabels remain aligned left.

I probably miss something very stupid but some help would be welcome :)

Jeff

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 29 Aug 2018, 11:04 AM
Hello Jeff,

The position of the hosted control can be adjusted by applying a padding to the layout control item. In order to calculate the correct padding, the layout would need to have passed, so a suitable place to do this is the Shown event of the form. In order to update the control`s location, it will be also necessary to call the UpdateControlBounds method on the item: 
private void RadForm1_Shown(object sender, EventArgs e)
{
    int padding = this.layoutControlItem3.ControlBoundingRectangle.Width - this.layoutControlItem3.AssociatedControl.Width;
    this.layoutControlItem3.Padding = new Padding(padding, 2, 2, 2);
    this.layoutControlItem3.UpdateControlBounds();
}

The same effect can be also achieved in the Visual Studio designer if you add an empty space to the right of your label. Then you should be able to adjust its position by dragging the splitter. I am attaching a short video demonstrating this approach. The end result should be similar using either approach.

I hope this helps. Let me know if you need further assistance.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
LayoutControl
Asked by
Jeff
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or