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

Alignment of wide text in RadComboBox

4 Answers 464 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 10 Feb 2012, 07:21 AM
Hi

As per this old thread for winforms controls (http://www.telerik.com/community/forums/winforms/combobox/alignment-of-wide-text-in-radcombobox.aspx) I need to left-align the text in a combobox, rather than right-align, after it is selected.

I have this code which works for ie9, but unfortunately I need it to also work for ie7 (o I hate u ie7 so much)
<telerik:RadComboBox ID="RadComboBox1" runat="server"
   Width="150px" DropDownWidth="300px"
   OnClientSelectedIndexChanged="AlignLeftAfterSelectedIndexChange">
</telerik:RadComboBox>
 
function AlignLeftAfterSelectedIndexChange(sender) {
    var input = sender.get_inputDomElement();
    input.setSelectionRange(0, 0);
}

Is there a more Telerik-friendly way to do it?

Cheers

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Feb 2012, 12:38 PM
Hello Jeremy,

You can easily left-align the text in a combobox after it is selected using CSS.
CSS:
<style type="text/css">
.RadComboBox .rcbInputCell .rcbInput
  {
     text-align:left!important;
  }
</style>

Thanks,
Princy.
0
Jeremy
Top achievements
Rank 1
answered on 13 Feb 2012, 02:02 AM
Sorry but that had absolutely no effect in ie7 or ie9. I can see that the style is applied by using the ie developer tools - but no difference in display.
0
Accepted
Ivana
Telerik team
answered on 13 Feb 2012, 12:54 PM
Hello Jeremy,

If you are trying to move the caret position at the beginning of the input in IE, you could refer to the following help article: Set caret position at the beginning of the input in IE, when the text of the selected item is too long.

I hope this helps.

All the best,
Ivana
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Jeremy
Top achievements
Rank 1
answered on 14 Feb 2012, 01:51 AM
Awesome! That works perfectly thanks!
Tags
ComboBox
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jeremy
Top achievements
Rank 1
Ivana
Telerik team
Share this question
or