-
Aug 15th, 2018, 02:23 AM
#1
Thread Starter
Frenzied Member
Exit Private Sub event
Hi to all:
When i load a Form, from my app, the form load an event that i show in code, and the first message when form loaded is the Msgbox that i have in that event.
Any way to not load this event in the first load?
This is the code:
Code:
Private Sub ListView1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles ListView1.ItemCheck
Dim fila As Integer
If TextBox21.Text = "" Then
MsgBox("Não selecionou nenhum registo")
Exit Sub
End If
For i = 0 To ListView1.Items.Count - 1
If ListView1.Items(i).Selected = True Then
fila = i
End If
Next i
numero_ID = ListView1.Items(fila).SubItems(4).Text
abrirBD_check()
check_var = e.NewValue
End sub
Thanks to all
-
Aug 15th, 2018, 02:46 AM
#2
Re: Exit Private Sub event
You can use a form-level variable (probably a Boolean) to say whether the form has finished loading or not.
Set it at the end of the Load event, and at the start of the ItemCheck event check if it has been set yet (exit if it isn't set).
-
Aug 15th, 2018, 02:49 AM
#3
Thread Starter
Frenzied Member
Re: Exit Private Sub event
OK...it's a way.
Thanks for the help
-
Aug 15th, 2018, 03:16 AM
#4
Thread Starter
Frenzied Member
Re: Exit Private Sub event
OK...it's a way.
Thanks for the help
-
Aug 15th, 2018, 03:20 AM
#5
Thread Starter
Frenzied Member
Re: Exit Private Sub event
Sory...
Annother question conserning the same subject.
When code detect the:
Code:
If TextBox21.Text = "" Then
MsgBox("Não selecionou nenhum registo")
Exit Sub
End If
that's mean user as click on the checkbox, and even the code as an "Exit Sub" the event put a check or uncheck on the checkbox...i mean the event continue working.
Any way to avoid this?
Thanks
-
Aug 15th, 2018, 03:28 AM
#6
Re: Exit Private Sub event
Events have an "e" parameter, which often contains useful data... in this case the data type is ItemCheckEventArgs, which contains these properties:
Originally Posted by https://msdn.microsoft.com/en-us/library/system.windows.forms.itemcheckeventargs(v=vs.110).aspx
CurrentValue Gets a value indicating the current state of the item's check box.
Index Gets the zero-based index of the item to change.
NewValue Gets or sets a value indicating whether to set the check box for the item to be checked, unchecked, or indeterminate.
I haven't checked the behaviour, but you may be able to set NewValue to make it automatically cancel the check/uncheck without re-running the event.
If not, you can use the values of the properties to check/uncheck the same item, but be aware it is likely to re-run the event.
Last edited by si_the_geek; Aug 15th, 2018 at 03:34 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|