Solved

winform events, vb.net

Posted on 2014-10-18
1
157 Views
Last Modified: 2014-10-24
The following is the list of events in my application:
 1  Form1_Load
 2  Sub FillComboboxes
 3  Sub cboCustomer_SelectedIndexChanged   
 4  Sub cboCustomer_SelectedIndexChanged
 5  Sub cboOrder_SelectedIndexChanged
 6  Sub EnableOrderQuantity
 7  Sub cboOrder_SelectedIndexChanged
 8  Sub EnableOrderQuantity
 9  Sub cboOrder_SelectedIndexChanged
10  Sub EnableOrderQuantity
11  Sub FillCustomeInfo
12  Sub TestRevised
13  Sub TestRevised
14  Sub TestRevised
15  Sub TestRevised
16  Sub TestRevised
17  Sub TestRevised
18  Sub TestRevised
19  Sub TestRevised
20  Sub EnableOrderQuantity
21  Sub FillInOrderDataGridVie

Open in new window


I have used a public variable "bolBypassCboOrder" to bypass line  "3  Sub cboCustomer_SelectedIndexChanged" via:
Private Sub cboOrder_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboOrder.SelectedIndexChanged
        strEvents += "Sub cboOrder_SelectedIndexChanged" & vbNewLine
       If bolBypassCboOrder Then
            bolBypassCboOrder = False
        Else
          ' other codes...
       End If
End Sub 

Open in new window

Q1: To produce list of events fired, is there a better way of doing that compare to my method by including a line like:
strEvents += "Sub cboOrder_SelectedIndexChanged" & vbNewLine in every event?

Q2: Is there a better way to bypass an event compared to my method of:
       If bolBypassCboOrder Then
            bolBypassCboOrder = False
        Else
          ' other codes...
       End If

Q3: Is it a good idea to supress the repeat events (line 12 through 19  Sub TestRevised)? If so, what is the best way of doing this?
0
Comment
Question by:Mike Eghtebas
1 Comment
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 40389924
Q1:

To record what happens in an application, you normally use Debug.WriteLine instructions that send the information to the Output window. They interfere less with your application than filling up strings.

This being said, unless you have the Ultimate versions of version that has a feature called IntelliTrace that can automatically trace what happens in the application, you have to manually code the tracing as you did.

Q2:

It depends on the conditions for which you might want to bypass the event.

If the condition is set True or False only from inside the event, then it is sometimes best to declare your variable inside the event itself, by using Static instead of Dim.

Static bolBypassCboOrder As Boolean

That way, you have a local variable, that is available only inside the event and cannot be changed by mistake somewhere else in the form. But it will keep its value in between calls if needed.

Q3:

It depends on which event is triggered (the name of the Sub does not tell that), and what it does.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question