Hello community, I'm trying to create a form with the sort methods
(Bubblesort and shell). The Sort algorithms work fine but my problem is
that I want to specify the length of the array and add the values. For
this I have 2 textbox and a button (insert), the first one is for the
length and the second textbox is where you type the value. When you
push the insert button the value in textbox2 will be inserted in the
array. I can insert values into an array but where I'm having trouble is
in the button. How can I call the button1_Click function in another
function(void insert) and put in in a for?
Thank you.
Loading
Sam HobbsPosted Jul 20, 2010, 2:36 AM
You asked how to "call the button1_Click function in another function". My suggestion is that you create a function that does what the button1_Click function does and then call the new function from the button1_Click functionand call only the new function in the button1_Click function. Then you can call the new function from anywhere you want to call it from to do whatever that the button1_Click function is now doing.
I do not understand what the problem is with doing that.
Tanmay SarkarPosted Jul 20, 2010, 12:28 AM
So i think every body can understand your problem.
Sam Hobbs Idea is good! but you not take it as you get a problem.
So please upload your file!
The Members may be understand your problem & should try to solve it.
Thank you!
Marco BlandonPosted Jul 20, 2010, 12:18 AM
Lakitha MunasinghePosted Jul 19, 2010, 11:29 PM
Sam HobbsPosted Jul 19, 2010, 1:34 PM
Amit ChoudharyPosted Jul 19, 2010, 7:47 AM
calling button click event:
Button1_Click(new Button(), null);
use it in your loop if you have certain databound with button then pass the button1 reference itself..
Please mark "Do you like this post?" if it helps you
Marco BlandonPosted Jul 18, 2010, 6:27 PM
Sam HobbsPosted Jul 18, 2010, 4:59 PM
You don't have to do the sorting yourself; you can use a collection that stores data in a sorted order; do you know how to do that?
Marco BlandonPosted Jul 17, 2010, 11:29 PM
Update:
Looking into casting, found the solution.
if ((int)vector[j] > (int)vector[j + 1])
{
int aux = (int)vector[j];
vector[j] = vector[j + 1];
vector[j + 1] = aux;
}
Thank you.
Lakitha MunasinghePosted Jul 17, 2010, 11:14 PM
So here you have to cast the objects...
if ( int.Parse(vactor[j]) > int.Parse(vector[j + 1]) )
{
int aux = int.Parse( vector[j] );
vector[j] = vector[j +1];
vector[j + 1] = aux;
}
Good Luck.
Lakitha Munasinghe
Marco BlandonPosted Jul 17, 2010, 10:50 PM