Reputation: 5001
i am setting text to a link label and adding these labels to a flow layout panel. It seems to be chopping off the ends of the link labels and as such i have labels with only 3/4's of the text. Does anyone know why this might be?
Thanks
Upvotes: 2
Views: 3531
Reputation: 11617
I'm not sure if you are adding the LinkLabels to the FlowLayoutPanel through code, but there is a property you can set to make them work properly.
var link = new LinkLabel();
link.Text = "Some really long string";
link.AutoSize = true; //This is really important!
FlowLayoutPanel1.Controls.Add(link);
If you don't set each LinkLabels AutoSize property, they just chop off any text that goes further than their default bounds.
Edit: My Testapp consists of placing a FlowLayoutPanel on the form, and a button to click, with the above code in the OnClick handler. Nothing else was changed on the form.
Without the AutoSize property set to true, I had the same problem you described. Setting it to True fixes it for me at least :)
Upvotes: 3
Reputation: 38200
Can you check the LinkArea
property of the link label .. the default is about 25.
I think you will have to set it to the maximum value you are using to display as text for the link label.
Upvotes: 0
Reputation: 250832
I have tested this by dropping a FlowLayoutPanel on a blank form and dropping in many LinkLabels. The width of the FlowLayoutPanel is narrow and I have tried adding Text properties to the link labels to break the layout.
Even putting text with no spaces in the link label doesn't cause the issue you describe - the text simply wraps around onto the next line.
Do you have any properties set on the link labels? This is the only way I could get this issue to occur.
I changed the size of one of the link labels to a fixed size smaller than the text and this pretty much did exactly what you report. I would suggest that the Width property of your link label is smaller than the text you are displaying.
Upvotes: 0