Reputation: 71
I have an application which uses a FlowLayoutPanel with a lot of Custom UserControls in it. The Custom UserControls contains a Label.
The problem: When the Label is updated the FlowLayoutPanel automatically scrolls it into view (Similar to the FlowLayoutPanel.ScrollControlIntoView() function).
This is the code snippet that makes the FlowLayoutPanel Scroll:
private void DownloadChanged(Object sender, DownloadProgressChangedEventArgs e)
{
progressDownload.Value = e.ProgressPercentage;
lblDownloaded.Text = e.BytesReceived.ToString() + " / " + e.TotalBytesToReceive.ToString();
}
I have been trying to find an event in the FlowLayoutPanel which I can intercept and stop it from scrolling when a child updates but I have not had any luck so far.
Is it possible to do this? If yes, how would I go about it? Thanks!
Upvotes: 3
Views: 1411
Reputation: 71
If having scrolling issues when clicking on a control in a FlowlayoutPanel, use an inherited control:
public class MyFlowLayoutPanel : FlowLayoutPanel
{
protected override System.Drawing.Point ScrollToControl(Control activeControl)
{
//return base.ScrollToControl(activeControl);
return this.AutoScrollPosition;
}
}
Upvotes: 6
Reputation: 71
Setting the the Label's AutoSize
Property to False seems to do the trick.
Read more here: Similar Issue
Upvotes: 1