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

Alignment of Editors

2 Answers 63 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Craig Booth
Top achievements
Rank 1
Craig Booth asked on 07 Jan 2010, 10:43 AM
While experimenting with a workaround, I was trying to closely align 3 editors so I could create a PropertyGrid style panel. Using the code below, the controls overlap each, but if I use the MS controls they align perfectly - am I missing something.

        Dim d As New RadTextBox
        d.Size = New System.Drawing.Size(95, 14)
        d.Location = New System.Drawing.Point(300, 200)
        d.Text = "Text One"
        TabItem4.ContentPanel.Controls.Add(d)

        Dim e As New RadDateTimePicker
        e.Size = d.Size
        e.Left = d.Left
        e.Top = d.Bounds.Bottom
        TabItem4.ContentPanel.Controls.Add(e)

        Dim f As New RadMaskedEditBox
        f.Size = d.Size
        f.Left = d.Left
        f.Top = e.Bounds.Bottom
        f.Text = "Text Two"
        TabItem4.ContentPanel.Controls.Add(f)

Any suggestions?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 07 Jan 2010, 12:28 PM
Hello Craig Booth,

Please note that the custom size that you set is not applied, no matter whether you are using Microsoft controls or RadControls. This is because the size of the editors is defined by the size of their font.

However, there is a difference between Microsoft controls and RadControls. Please note that when you set the Size.Height of a TextBox to 14, its Bounds.Bottom is still the default 20.

If you set the Size.Height of a RadTextBox to 14, you will get 14 for its Bounds.Bottom, but not 20. They will get their height of 20 at a later moment. This is done for optimization purposes. In order to get the real Bounds in your case, you should call the LoadElementTree() method:
Dim d As New RadTextBox
d.Size = New System.Drawing.Size(95, 14)
d.Location = New System.Drawing.Point(300, 200)
d.Text = "Text One"
TabItem4.ContentPanel.Controls.Add(d)
d.LoadElementTree()

Dim e As New RadDateTimePicker
e.Size = d.Size
e.Left = d.Left
e.Top = d.Bounds.Bottom '20
TabItem4.ContentPanel.Controls.Add(e)
e.LoadElementTree()

Dim f As New RadMaskedEditBox
f.Size = d.Size
f.Left = d.Left
f.Top = e.Bounds.Bottom '20
f.Text = "Text Two"
TabItem4.ContentPanel.Controls.Add(f)

I hope this helps. If you have additional questions, feel free to contact me.

Sincerely yours,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Nikolay
Telerik team
answered on 19 Jul 2011, 02:47 PM
Hi Craig,

Have you heard the good news? A week ago we released RadControls for WinForms Q2 2011 and there we introduced the RadPropertyGrid for WinForms. Feel free to register for the Free Webinar for Desktop Developers that will take place on July 20.

Best wishes,
Nikolay
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
TextBox
Asked by
Craig Booth
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or