G
Guest
Event handler anomaly
I pattern my lookup forms according to chapter 13 of ado.net core reference.
With some tweaks and additions from things I've learned in these newsgroups,
they work fine.
Recently, a form went bad. I have a form based on an authors table. I
added some fields to a table called authors2, and added the data. I copied
the usual buttons from the authors forms << < > >> Edit Add Delete Update
Cancel SubmitChanged, Close. I have a grid on the form as well, called dgrd.
Textboxes, comboboxes and a checkbox for a boolean field. I added the
underlying code from the authors form, then made all of the adjustments.
For a bizarre reason, when I doubledclicked the add button, instead of the
add button code, I got a new private sub called Click_1. Mind, the original
sub was there. Same with every button except form load. In the end I made
additional controls and new data adapters and a dataset, etc. I filled in
the new click_1 event with the same code.
Private Sub btnAdd_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
cm.AddNew()
bAdd = True
Me.cboAuthorType.SelectedIndex = 1
Me.cboContentRights.SelectedIndex = 1
Me.cboPointOfView.SelectedIndex = 1
Me.cboPrimaryPub.SelectedIndex = 1
Me.cboAuthorType.SelectedIndex = 0
Me.cboContentRights.SelectedIndex = 0
Me.cboPointOfView.SelectedIndex = 0
Me.cboPrimaryPub.SelectedIndex = 0
SetEditMode(True)
Me.dgrd.Enabled = False
End Sub
Here's a problem. Under certain conditions when this form is called by
another form, I want some selected text added to a new entry. I do this
through a Authors2CallingForm property (as string). If the value is "TFS2" I
want the addnew button clicked and the selected text put in the right place.
The details don't matter here.
I can't use the btnAdd.PerformClick() method because of the click_1 problem,
in the form_load event procedure. So I created a Authors2Add sub that had
the exact same code as the above, and call it from the form_load procedure.
But it doesn't work the same. If I click the add button, all the boxes
clear. But when I call the subroutine, I'm on item 12 of 13. If I click the
move next button all the boxes clear and the text is in the right place. But
this causes other problems.
I don't understand why the subroutine doesn't produce the same results as
clicking the add button.
As an alternative, is there a way of calling click_1 from form_load that
will produce the same result as clicking the add button?
thanks.
dennist685
I pattern my lookup forms according to chapter 13 of ado.net core reference.
With some tweaks and additions from things I've learned in these newsgroups,
they work fine.
Recently, a form went bad. I have a form based on an authors table. I
added some fields to a table called authors2, and added the data. I copied
the usual buttons from the authors forms << < > >> Edit Add Delete Update
Cancel SubmitChanged, Close. I have a grid on the form as well, called dgrd.
Textboxes, comboboxes and a checkbox for a boolean field. I added the
underlying code from the authors form, then made all of the adjustments.
For a bizarre reason, when I doubledclicked the add button, instead of the
add button code, I got a new private sub called Click_1. Mind, the original
sub was there. Same with every button except form load. In the end I made
additional controls and new data adapters and a dataset, etc. I filled in
the new click_1 event with the same code.
Private Sub btnAdd_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
cm.AddNew()
bAdd = True
Me.cboAuthorType.SelectedIndex = 1
Me.cboContentRights.SelectedIndex = 1
Me.cboPointOfView.SelectedIndex = 1
Me.cboPrimaryPub.SelectedIndex = 1
Me.cboAuthorType.SelectedIndex = 0
Me.cboContentRights.SelectedIndex = 0
Me.cboPointOfView.SelectedIndex = 0
Me.cboPrimaryPub.SelectedIndex = 0
SetEditMode(True)
Me.dgrd.Enabled = False
End Sub
Here's a problem. Under certain conditions when this form is called by
another form, I want some selected text added to a new entry. I do this
through a Authors2CallingForm property (as string). If the value is "TFS2" I
want the addnew button clicked and the selected text put in the right place.
The details don't matter here.
I can't use the btnAdd.PerformClick() method because of the click_1 problem,
in the form_load event procedure. So I created a Authors2Add sub that had
the exact same code as the above, and call it from the form_load procedure.
But it doesn't work the same. If I click the add button, all the boxes
clear. But when I call the subroutine, I'm on item 12 of 13. If I click the
move next button all the boxes clear and the text is in the right place. But
this causes other problems.
I don't understand why the subroutine doesn't produce the same results as
clicking the add button.
As an alternative, is there a way of calling click_1 from form_load that
will produce the same result as clicking the add button?
thanks.
dennist685