Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

winform events, vb.net

Posted on 2014-10-18
1
Medium Priority
?
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 2000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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 long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

730 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