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

CheckedDropDownList Text Allignment

4 Answers 12 Views
CheckedDropDownList
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 12 Feb 2021, 08:10 PM

How do you align the text in the TextBox area? 

I tried both CheckedDropDownListElement.EditableElement.TextBox.Alignment

and also CheckedDropDownListElement.TextBox.Alignmentbut but neither has any affect.

It is always TopLeft.

4 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 12 Feb 2021, 08:41 PM

Also, if you try to set these alignments in the Element hierarchy editor it causes an exception.

It appears to mix up control types and it causes an invalid cast

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 Feb 2021, 01:41 PM

Hello, John, 

RadCheckedDropDownList internally uses a RadAutoCompleteboxElement for displaying the tokens:

In order to change the text alignment, you can set the CheckedDropDownListElement.AutoCompleteEditableAreaElement.AutoCompleteTextBox.TextAlign property to one of the available options: 

this.radCheckedDropDownList1.Font = new Font("Arial", 12f, FontStyle.Regular);          this.radCheckedDropDownList1.CheckedDropDownListElement.AutoCompleteEditableAreaElement.AutoCompleteTextBox.TextAlign = HorizontalAlignment.Center;

The following RadCheckedDropDownList is multiline and enlarged height, but the text is centered:

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
John
Top achievements
Rank 1
answered on 16 Feb 2021, 05:04 PM

Hi Dess.

Thank you for the reply. This setting helps for horizontal alignment, but not for vertical.
However, I figured out how to get vertical alignment by investigating the structure of the component. The code below works.

AutoCompleteBoxViewElement control = radCheckedDropDownList1.GetChildAt(0).GetChildAt(2).GetChildAt(0).GetChildAt(0).GetChildAt(0) as AutoCompleteBoxViewElement;

control.Alignment = ContentAlignment.MiddleCenter;
control.Padding = new System.Windows.Forms.Padding(5);
control.MinSize = new System.Drawing.Size(0, 20);
control.MaxSize = new System.Drawing.Size(0, 20);

As I mentioned in my previous reply, there is a bug in the Element hierarchy editor.
It is mistakenly adding an extra .GetChildAt(0) in the Designer. (See attached image)
The next to last GetChildAt(0) points to a AutoCompleteBoxViewElement, which has no children. So the last .GetChildAt(0) will cause an exception.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Feb 2021, 02:07 PM

Hello, John, 

I am glad that you have found a suitable solution for your case to accomplish the desired vertical alignment.

As to the error message, indeed, it is not good user experience. The TextBlockElement that you are managing in the UI editor at design time is created when the layout for the control is performed, e.g. in the Load event. That is why accessing it as a child at an earlier moment wouldn't give you access to this element. 

I have logged it in our feedback portal by creating a public thread on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

I have also updated your Telerik points.

Currently, the possible solution to access this TextBlockElement is to do it in the form's Load event, not earlier.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
CheckedDropDownList
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or