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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top