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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Flowlayout and autosizing labels

Thread ID:





15835 Jun 28,2004 09:14 PM UTC Jun 29,2004 03:30 PM UTC WinForms 1
Tags: Tools
Asked On June 28, 2004 09:14 PM UTC

Is there any way I can get a label (ie. text) to be fully justified as part of a flow layout. In other words I have a panel which has a paragraph of text above it contained in a form and I want that paragraph of text to change its height according to the width of the form. The flow layout would take care of moving the panel below the text. Is this possible? Its something you get for free in HTML and i was surprised to see that neither microsoft nor syncfusions label controls allow for multi-line. any ideas? thanks -andy

Administrator [Syncfusion]
Replied On June 29, 2004 03:30 PM UTC

Hi Andy Here is a sample that demonstrates what you are looking for. - You need to set the Minimumsize proprty for the Form. - For the FlowLayout component, you need to set the LayOutMode to be Vertical and you also need to provide LeftMargin and RightMargin:. - To autosize the label control when you increase/decrease the form width, you need to listen to the FlowLayout''s ProvideLayoutInformation event to set the PreferredSize for the Label control. You have to do this because the .NET label contrOl does not have a concept of PreferredSize. private void flowLayout1_ProvideLayoutInformation(object sender, Syncfusion.Windows.Forms.Tools.ProvideLayoutInformationEventArgs e) { if (e.Control == this.label1 && e.Requested == LayoutInformationType.PreferredSize) { Graphics g = this.CreateGraphics(); SizeF szPref = g.MeasureString(this.label1.Text, this.label1.Font, this.ClientRectangle.Width); e.Size = new Size(this.ClientRectangle.Width-20, (int)szPref.Height + 5); e.Handled = true; g.Dispose(); } } Regards Arun


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon