Combo and Text Box issue at App Startup

Combo and Text Box issue at App Startup

am 06.01.2008 19:53:14 von UR

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

Re: Combo and Text Box issue at App Startup

am 06.01.2008 20:01:48 von notmyfirstname

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

Re: Combo and Text Box issue at App Startup

am 06.01.2008 21:30:49 von UR

With Deft Fingers, "Cor Ligthert[MVP]" wrote:

>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