Jelmer Posted July 27, 2006 Posted July 27, 2006 Hello.. I've got a big problem... On a form, i have a button called Delete If i press delete this code runs: private void btnWissen_Click(object sender, EventArgs e) //Verwijderen!! { product.verwijderen(Convert.ToInt16(txtID.Text)); System.Windows.Forms.Application.DoEvents(); txtReset_Click(sender, e); } The product is removed (that works). Than i wait... Then the code of the button txtReset_Click is runned... But the last one doestn't do anything... Also not if i copy and past the code to here... If i run the program, and after i pushed on Delete, and then on txtReset it works well.. What is wrong???????????? Quote
Cags Posted July 27, 2006 Posted July 27, 2006 It would help if you posted the code from the txtReset_Click method. One thing you may be doing wrong, if you are using the sender object at all in the txtReset_Click event it would work when you click on the txtReset but not when you clicked the btnWissen since you would have passed down the button not the textbox. Quote Anybody looking for a graduate programmer (Midlands, England)?
Jelmer Posted July 27, 2006 Author Posted July 27, 2006 Ok: private void txtReset_Click(object sender, EventArgs e) { Productenladen_Load(sender,e); } private void Productenladen_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'billingMDB.Bedrijven' table. You can move, or remove it, as needed. //this.bedrijvenTableAdapter.Fill(this.billingMDB.Bedrijven); // TODO: This line of code loads data into the 'billingMDB.FactuurRegels' table. You can move, or remove it, as needed. //this.factuurRegelsTableAdapter.Fill(this.billingMDB.FactuurRegels); // TODO: This line of code loads data into the 'billingMDB.Producten' table. You can move, or remove it, as needed. //this.productenTableAdapter.Fill(this.billingMDB.Producten); try { this.Cursor = Cursors.AppStarting; System.Windows.Forms.Application.DoEvents(); //status.Text = "Klantgegevens inlezen"; //Klantgegevens laden product = new Class_products(0, "", 0, "", 0, 0); product.open("SELECT * FROM Producten order by Naam"); product.read(); product.first(); int ex; ex = Convert.ToInt16(product.return_id()); MessageBox.Show(Convert.ToString(ex) + " / " + Convert.ToString(mobiel)); mobiel = 0; laden(); } finally { this.Cursor = Cursors.Default; //status.Text = "Gereed"; } } Quote
Administrators PlausiblyDamp Posted July 28, 2006 Administrators Posted July 28, 2006 Rather than calling the _Click event of the button have you tried using it's .PerformClick() method? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jelmer Posted July 28, 2006 Author Posted July 28, 2006 there is only on method.. thats the onclick... Quote
Cags Posted July 28, 2006 Posted July 28, 2006 OnClick isn't a method it's an event. What PlausiblyDamp is suggesting is that instead of calling the method attached to the OnClick event (txtReset_Click(sender, e);) you instead call txtReset.PerformClick(). Quote Anybody looking for a graduate programmer (Midlands, England)?
Jelmer Posted July 28, 2006 Author Posted July 28, 2006 so i need to replace it to txtReset.PerformClick() ? Quote
Denaes Posted July 28, 2006 Posted July 28, 2006 I've found the easiest way for me (I get confused sometimes with having handlers floating all around) is to take to the code from Reset and put it in a function. Call the function from btnWissen_Click & txtReset_Click.... and it looks like txtReset_Click is calling another event (the form load event?). So, in my simple eyes, that code that you want to call from three different events should just be a function called directly. In C# I would definately do it this way. In VB.Net I might just as well play with the handlers because I'm more comfortable with vb.net... but I still don't like the idea of multiple procedures handling the same event. Just confuses me on the bookkeeping end. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.