Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4625162
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:13:57+00:00 2026-05-22T03:13:57+00:00

I have a custom UserControl that have a StatusStrip. So, I resize this control

  • 0

I have a custom UserControl that have a StatusStrip. So, I resize this control when user drags the corner of this status strip. However, the resizing is not pretty good: temporary white areas can be observed on the parent control during the resize, and sometimes if the resizing are too fast user “loses” the control(that stops resizing).

enter image description here

Option Infer On

Public Class FloattingGrid
  Inherits System.Windows.Forms.UserControl

  Dim mouseDownLocation As Nullable(Of Point)

  Private Sub StatusStrip1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles StatusStrip1.MouseMove

    If mouseDownLocation.HasValue Then
      Dim newPosition = Cursor.Position
      Dim dx = newPosition.X - mouseDownLocation.Value.X
      Dim dy = newPosition.Y - mouseDownLocation.Value.Y
      'Dim oldRect = New Rectangle(Me.Location, Me.Size)'
      Me.Size = New Size(Me.Width + dx, Me.Height + dy)
      mouseDownLocation = newPosition

      If Me.Parent IsNot Nothing Then
        'Me.Parent.Invalidate(oldRect) '
        Me.Parent.Refresh()
      End If
    Else

      If e.X > Me.Width - 20 Then
        If Cursor <> Cursors.SizeNWSE Then Cursor = Cursors.SizeNWSE
      Else
        If Cursor = Cursors.SizeNWSE Then Cursor = Cursors.Default
      End If
    End If
  End Sub

  Private Sub StatusStrip1_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusStrip1.MouseLeave
    Cursor = Cursors.Default
    mouseDownLocation = Nothing
    'Me.ResumeLayout() '
  End Sub

  Private Sub StatusStrip1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles StatusStrip1.MouseDown
    If Cursor = Cursors.SizeNWSE Then
      'Me.SuspendLayout() '
      mouseDownLocation = Cursor.Position
    End If
  End Sub

  Private Sub StatusStrip1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles StatusStrip1.MouseUp
    mouseDownLocation = Nothing
    'Me.ResumeLayout()'
  End Sub

  ' Private Sub FloattingGrid_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove '    
  ' End Sub '

  Private Sub FloattingGrid_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.ResizeRedraw = True
  End Sub
End Class

I think that behavior could be caused by the parent’s Invalidate. Is there a way to just BeginInvalidate and not wait till parent invalidates all the region?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:13:58+00:00Added an answer on May 22, 2026 at 3:13 am

    BeginInvoke has nothing to do with painting and nothing to do with implementing a delay. It’s all about cross-thread access, which you’re not doing here. It’s not the correct solution.

    And there’s nothing wrong with calling Invalidate. It just marks the area as requiring painting. It doesn’t actually cause that area to get repainted multiple times. If the area you invalidate has already been invalidated, it’s a no-op, so it’s not responsible for slowing anything down here. If you wanted it to be repainted immediately, you would need to call something like Refresh instead.

    One thing you could do is prevent the parent control from trying to resize itself and change the layout of its child controls to accommodate the new position of the StatusStrip. To do that, call the SuspendLayout method when you begin resizing and the ResumeLayout method when you finish.

    Of course, that’s not guaranteed to solve your problem. You’re still very likely to see a lag and white or black areas appear in the regions that haven’t been painted yet. This happens in other applications and even when you resize windows. The only solution to that is double-buffering, drawing everything into a temporary background buffer, and then painting that entire completed image to the screen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an custom control that extend System.Web.UI.UserControl. Is it possible to inherit user
I have a custom user control that contains asp:ValidationSummary . It is placed on
I have a Custom usercontrol that I want to enlarge. I tested this whit
I have a custom templated control(toolbar) that contains a custom usercontrol(button) The button uses
I have a custom user control with a textbox on it and I'd like
I have a custom validation function in JavaScript in a user control on a
I have a custom UserControl that I created as a navigation menu that parses
I have made a custom UserControl i Vb.net (windows application). How can I add
I have a few models that need to have custom find conditions placed on
hi i would like to create a custom calendar, this calendar will have custom

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.