I could not make the horizontal scrollbar go away completely, but with this code I was able to almost fix both of the problems you identified. When resizing quickly, the horizontal scrollbar flickers, but it doesn't remain on the screen. And when the vertical scrollbar appears, it does another layout to remove the horizontal scrollbar.
Here is my revised ClientSizeChanged event handler:
private void flw_chat_ClientSizeChanged(object sender, EventArgs e)
{
if (CurrentFlowWidthWidth != flw_chat.ClientSize.Width || flw_chat.HorizontalScroll.Visible)
{
CurrentFlowWidthWidth = flw_chat.ClientSize.Width;
foreach (Control c in flw_chat.Controls)
c.Width = CurrentFlowWidthWidth - c.Margin.Horizontal - 4;
}
}
And here is my revised code to add a new control:
private void AddControl_Click(object sender, EventArgs e)
{
var temp = new Button();
temp.Text = "AAA";
if (CurrentFlowWidthWidth != flw_chat.ClientSize.Width)
flw_chat_ClientSizeChanged(null, null);
temp.Width = CurrentFlowWidthWidth - temp.Margin.Horizontal - 4;
flw_chat.Controls.Add(temp);
if (flw_chat.HorizontalScroll.Visible)
flw_chat.PerformLayout();
}