Solved

winform events, vb.net

Posted on 2014-10-18
1
148 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now