We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to change the horizontal text alignment for the selected value of combo box.

How to change the horizontal text alignment for the selected value of combo box?

I am using SfComboBox to lad Arabic data as well, when using flow direction the drawer appears correctly but the Watermark text and the selected text appears on the other end. How can I center align or left align the selected text and the water mark.

Please advise.

7 Replies

DR Dhanasekar R Syncfusion Team January 22, 2019 03:37 AM

Hi Sadhik, 
 
Greeting from Syncfusion. 
 
We have implemented the ComboBox by inheriting the Entry control. On setting FlowDirection to RightToLeft, the entry text will be aligned always on left corner of the control, so Watermark of the ComboBox will behaves as like entry text. We have achieved your requirement for aligning selected item center using custom renderer. Please have the code snippet, sample with screenshot below. 
 
 public class CustomRenderer : SfComboBoxRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<SfComboBox> e)
        {
            base.OnElementChanged(e);
            Control.TextField.TextAlignment = UIKit.UITextAlignment.Center;
        }

    } 
 
 
 
 
 
Regards, 
Dhanasekar 



GA Ghaith Abu Hakmeh April 16, 2020 12:56 PM

Can I Do horizontal text alignment for the selected value of combo box In Android and Thanks


RS Ramya Soundar Rajan Syncfusion Team April 17, 2020 06:17 AM

Hi Ghaith, 

Greetings from Syncfusion.

We have prepared the sample with the custom renderer to achieve your requirement in Android platform. Please find the below code snippet and sample for this,

Code Snippet:  
CustomRenderer.cs:

public class CustomRenderer : SfComboBoxRenderer
 
    { 
        public CustomRenderer(Context context) : base(context) 
        { 
        } 
 
        protected override void OnElementChanged(ElementChangedEventArgs<SfComboBox> e) 
        { 
            base.OnElementChanged(e); 
            Control.GetAutoEditText().Gravity = GravityFlags.Center; 
        } 
    } 
 
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ComboBoxSample2132919719

Please check with the above sample and let us know if you have any concern. 
 
Regards, 
Ramya S 



LL Lisa Lazu April 19, 2020 07:54 PM

You were great and everyone received so much from your experience and knowledge
Absolutely amazing, thank you for sharing your knowledge with me.
Good Idea isc888


SP Sakthivel Palaniyappan Syncfusion Team April 19, 2020 09:38 PM

Hi Lisa,

Thanks for your valuable feedback.

Please let us know if you have any other queries.

Regards,
Sakthivel P.
 



CM Christine Maria replied to Ramya Soundar Rajan July 15, 2021 09:01 PM

Thanks for sharing a great article.

You are providing wonderful information, it is very useful to us.

Keep posting like this informative articles.

Thank you.


Get to know about : LSM99 แทงบอลออนไลน์




SS Suganya Sethuraman Syncfusion Team July 19, 2021 03:36 AM

Hi Christine,

Thanks for the update.

Please let us know if you have any other queries.

Regards,
Suganya Sethuraman.
 


Loader.
Live Chat Icon For mobile
Up arrow icon