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.
ADAdministrator Syncfusion Team June 29, 2004 10:30 AM
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;