I have a ListView that we resize to move the right side to leave room for different controls depending on user inputs. After the resize I do...
lvProps.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
lvProps.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
It works, the column sizes are correct and looks good, but while this code is running you can see the widths get smaller and the larger again. It is very distracting.
I'm sure this is a simple thing, but what is the best way to stop the display during the brief period while these are being resized?
You could try turning drawing off/on with WM_SETREDRAW:
// ... at Form level ...
private const int WM_SETREDRAW = 11;
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
// ... some method ...
SendMessage(lvProps.Handle, WM_SETREDRAW, false, 0); // turn updates off
lvProps.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
lvProps.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
SendMessage(lvProps.Handle, WM_SETREDRAW, true, 0); // turn updates back on
lvProps.Invalidate();
lvProps.Refresh();