SamKr
8/8/2017 - 3:53 PM

Lock control

Lock control

 [System.Runtime.InteropServices.DllImport("user32.dll")]
  public static extern bool LockWindowUpdate(IntPtr hWndLock);

  internal void FillTB(TextBox tb, string mes) 
  {
     try
     {
        LockWindowUpdate(tb.Handle);

        // Do your thingies with TextBox tb
     }
     finally
     {
        LockWindowUpdate(IntPtr.Zero);
     }
  }
namespace System.Windows.Forms
{
    public static class ControlExtensions
    {
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        public static extern bool LockWindowUpdate(IntPtr hWndLock);

        public static void Suspend(this Control control)
        {
            LockWindowUpdate(control.Handle);
        }

        public static void Resume(this Control control)
        {
            LockWindowUpdate(IntPtr.Zero);
        }

    }
}