Combo and Text Box issue at App Startup

  • Thread starter Thread starter Mr. B
  • Start date Start date
M

Mr. B

In my application, I have a Combo Box and Text Box.

At Startup, I fill the Combo Box with information that I allow the Users to
select to do certain Calculations.

My Text Box shows a Value calculated by the information in the Text Box.

At Startup, I have Default information in both boxes.

Right now, a User selects a different line item in the Combo Box... and when
they Select the CALC button, the TEXT box is updated.

What I would like to do is to have the Text Box updated as soon as a User
changes the Combo Box.

But when I do the "SelectedIndexChanged", my Startup Fails as the application
is trying to run this or something.

How do I get around this issue?

Thanks in advance.

BruceF
 
Mr B,

This is a problem with all ListBoxes. It initialize its bindings even before
the Form Load event.

The most simple way for VB Net users is to put a private bool before your
code.
Be aware that you cannot use Option Infer with global members.

private DataSourcesAreSet as bool = true;

In the load form event you set then at the end:
DataSourcesAreSet = true

In your combobox index changes event you place then at the start

If DataSourcesAreSet = False then return

A more elegant solution is to remove the standard created add handler in the
index change event and set that in the load event by using the AddHandler.

Cor
 
Cor Ligthert said:
The most simple way for VB Net users is to put a private bool before your
code.

Excellent... that worked!!!
Be aware that you cannot use Option Infer with global members.

Not a problem for me. It's a pretty simple application.

Thanks again!!!

BruceF
 
Back
Top