Need resize events, not minimise/restore?

  • Thread starter Thread starter null
  • Start date Start date
N

null

Hello
I have a listbox in my form, which I want to clear if the form's
hieght changes. I am having difficulty with that, as it seems
when the form is minimised the height changes, this is not
what I need, I need only changes to non minimised sizes, i.e.
when the user uses the mouse to increase the size?
 
null said:
Hello
I have a listbox in my form, which I want to clear if the form's
hieght changes. I am having difficulty with that, as it seems
when the form is minimised the height changes, this is not
what I need, I need only changes to non minimised sizes, i.e.
when the user uses the mouse to increase the size?
Check WindowState:

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
'
If Not Me.WindowState = FormWindowState.Minimized Then
ListBox1.Items.Clear()
End If

End Sub

However, with the code above ListBox gets cleared when the minimized form is restored. If you
do not want to clear ListBox when the form is restored:

Private g_IsRestoreNextResizeEvent As Boolean

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
'
If Me.WindowState = FormWindowState.Minimized Then
g_IsRestoreNextResizeEvent = True
ElseIf g_IsRestoreNextResizeEvent Then
g_IsRestoreNextResizeEvent = False
Else
ListBox1.Items.Clear()
End If

End Sub

Hope this helps.
 
Back
Top