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

SfCheckbox text line break

Hi, at the moment my text for the checkbox is greater than the screen width. I'm wondering how do I get the text to wrap/line break when the width is large.  

1 Reply

BK Bharathiraja K Syncfusion Team May 3, 2019 09:35 AM UTC

Hi Minh Tran, 
 
Thanks for contacting Syncfusion support. 
 
Query: How do I get the text to wrap/line break when the width is large.  
 
SfCheckBox's text has been wrapped automatically in Android and UWP platforms. For iOS, we have achieved your requirement using SizeThatFits override method in custom renderer (CheckBox_IndeterminateState.iOS/ CheckBoxRenderer) of SfCheckBox control.  Please download the sample in below link  
 
 
Code Example [C#]: 
 public override CGSize SizeThatFits(CGSize size)
        {
            var sizeValue = base.SizeThatFits(size);
            var text = Control.TitleLabel.Text;
            if (!string.IsNullOrEmpty(text))
            {
                NSString nsstring = new NSString(text);
                UIStringAttributes attribs = new UIStringAttributes
                {
                    Font = Control.Font,
                    ParagraphStyle = new NSMutableParagraphStyle()
                    {
                        LineBreakMode = UILineBreakMode.CharacterWrap
                    }
                };

                CoreGraphics.CGRect textSize = nsstring.GetBoundingRect(new CGSize(width, double.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin, attribs, null);
                float strikeHeight = (float)textSize.Height;

                return new CGSize(sizeValue.Width, strikeHeight);
            }

            return sizeValue;
        }
 
 
Please let us know, if you have any other queries. 
 
Regards, 
Bharathi. 


Loader.
Live Chat Icon For mobile
Up arrow icon