Form and Combo Initialize problem...

  • Thread starter Thread starter Jan Nielsen
  • Start date Start date
J

Jan Nielsen

Hi
I have a form with a combo on it
The combos items is a list of groups (ie coworker, parent, friend) which it
gets from a dataset when the form loads.
When the user selects a group from the combo my code selects all persons in
this group (using a dataview) and generates an email for them. It all works
well.
Except when I load the form. I have my Dataadapter.Fill placed in the forms
Load procedure.
When I use a Dataadapter.Fill(Dataset that is combos recordsource) the
SelectedIndexChanged of the combo gets invoked.
This calls my SendEmail function (btw with an empty dataview but that is not
really interesting here)

MY PROBLEM:
Is there a way to tell the form that this is initializing so it should skip
the SendEmail function.

I suddenly realized that I have read that the .BeginInit was supposed to do
so so

I tried to move my FillDataAdapter function to right after
InitializeComponent() in the Windows generated code.

And I also tried to place my FillDataAdapter function right before the end
of the Windows Region.

But now my function creates 3 emails (ie the Create email function still
gets called but now the dataview is filled with the records of the first
item.)


Can anyone help?

Best regards
Jan
 
Hi Jan,

I hate it to use switches, but for that Combo box I have to use them. I
have again took a very long time to overcome it. I could eliminate it
(although the way I do it is a normal switch method, because I test of the
first table in the dataset exist).

Be aware that the Combobox is famous because his bugs, I don't know if your
problem is one of them. Most bugs about which people start tell here are
mostly no bugs, but in the case of the combobox be awared.

Cor
 
Hi again Cor
I would like to avoid workarounds until I am quite sure there is no "right"
way of doing it.
And I think my problem is more than a combo problem.

I would like the events of _all_ a forms controls to be suspended when the
form is initialized. It could be listboxes, textboxes etc. IE if you add a
Private Sub txtFornavn_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtFornavn.TextChanged
MsgBox("test")
End Sub
To a form and txtforavn is databound, TextChanged is invoked when the form
is drawn the first time.

Right now I have made a boolean that checks if it is first time, but this is
a workaround.
I hoped for a better way.

Best regards

Jan
 
Back
Top