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

Left aligning text boxes in a button group

3 Answers 122 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Jason Eskew
Top achievements
Rank 1
Jason Eskew asked on 07 Apr 2010, 07:05 PM
I'm currently evaluating the RadRibbonBar and I've come across an issue.

I'm trying to create a stack of three fields with labels:
lblStartFreq txtStartFreq
lblEndFreq    txtEndFreq
lblStepSize    cboStepSize

Currently, each row is contained in a horizontal button group and the entire set of three button groups is in a single vertical button group.  I couldn't find a tableLayoutPanel which would have worked better for grouping these items.

My problem is that the label text size is variable width.  This is especially true in localized versions of my application.  But, I'd like to have the three text boxes left aligned to the widest label.

I've tried setting the lblStartFreq.size.width property and the txtStartFreq.Location.x property but receive the following error in VS2010 each time: "Expression is a value and therefore cannot be the target of an assignment." 

Either of these properties can be set on a normal .net WinForms control but and intellisense indicates that these are get/set values on the radControl versions of the controls.  But they don't seem to be exposed.

Is there a different method to aligning these controls that I'm missing or is this something that the Telerik Ribbon Bar isn't capable of doing at this time?

Thanks,

Jason

3 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 13 Apr 2010, 09:42 AM
Hi Jason,

Thank you for contacting us and for your questions.

You can simply add white spaces to the end of the shorter labels' text to make them wider and thus make the next label aligned as you require.

I hope this helps. Do not hesitate to write back anytime you have further questions or need assistance.

All the best,
Deyan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jason Eskew
Top achievements
Rank 1
answered on 13 Apr 2010, 01:10 PM
"You can simply add white spaces to the end of the shorter labels' text to make them wider and thus make the next label aligned as you require."

Uh....  right.  How much white space?  It's a proportional font and the text string CHANGES based on the localized language of the users culture.

Intellisense indicates that the width property has a getter and a setter but when you actually try to set the value, you get an error indicating that the property is read only.  So, not only is the property missing the setter, the associated XML comment in the Telerik code is incorrect.

Jason
0
Accepted
Deyan
Telerik team
answered on 13 Apr 2010, 05:36 PM
Hello Jason,

Thanks for getting back to me and for the further details.

I am sorry for the misunderstanding. It seems that I did not get the idea correctly.

Setting the Location or Size property will not function while the AutoSize property of the RadLabelElement is true. If you wish to manually adjust the size of the RadLabelElement, you should simply set its AutoSize property to false. This will serialize an explicit Bounds property setting in the InitializeComponent method for the element and this setting will be altered each time you resize the element.
 
However, I think there is more elegant way to build up your label hierarchy in order to achieve an effect of aligning the right labels to the longest left label. The idea is to create one horizontal button group with two vertical button groups inside. You can set the ShowBorder property of these two groups to false. Then, in the left button group you insert the frist column of labels (lblStartFreq, lblEndFreq, lblStepSize) and in the second group you insert the other three labels accordingly. In this way, our layout system will automatically calculate the width of the groups according to the widest label inside and the content in them will be dynamically aligned as you require.

I have prepared a sample WinForms application that demonstrates the scenario. Please refer to the attachment for further details and do not hesitate to get back to me in case further questions arise.
 
Best wishes,
Deyan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
RibbonBar
Asked by
Jason Eskew
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Jason Eskew
Top achievements
Rank 1
Share this question
or