How do I code if I am coding what will happen if I press a button. and then ask a question and want to wait until either of two others buttons are pressed like an yes or no question
say i code something and to continue i need the answer like 0=no 1=yes and return that value to the first button code depending on which other button i pressed to answer the question

        private void dostuff_Click(object sender, EventArgs e)
        {
                //code code 
                //need answer to question
                //and then get a return value depending on which of the
                //two below i press
        }
        private void no_Click(object sender, EventArgs e)
        {

        }
        private void yes_Click(object sender, EventArgs e)
        {

        }

How about using a message box with the Yes/No buttons option?

switch (MessageBox.Show(prompt, caption, MessageBoxButtons.YesNo)) {
    case DialogResult.Yes:
        // Do something for yes
        break;
    case DialogResult.No:
        // Do something for no
        break;
}

mhm dont se how i can fit that in here like i dont have YesNo buttons that was just an example i need to know 1 or 10.
more like this

private void dostuff_Click(object sender, EventArgs e)
{
//press this button to start the program
int value;
//code code "how old are you? press button 1 or 10"
//and then you press one button and i get 1 or 10 return
//so i can further use it with my local variable
//so i dont have to make an global one
}
private void 1_Click(object sender, EventArgs e)
{
}
private void 10_Click(object sender, EventArgs e)
{
}

i dont have YesNo buttons that was just an example

It would be prudent to explain exactly what you want. It's irritating when I give a viable answer to a question and then the response is "that won't work because what I asked for isn't really what I need".

Im sorry i just didnt know how to explain it well but i guess what i seach is like an overload method so i can get a return to my first button code

The adaption to Deceptikon's response here would be to make a custom form that looks like a message box proving two buttons, 1 and 10, and then use .ShowDialog() on the customer form to display it modally, therefore forcing a response to the form before continuing.

You could then assign the form returning a yes reponse to the 1 button and a no to the 10 button creating what you require.

Im sorry i just didnt know how to explain it well

You don't need to explain the mechanics, just the intended behavior. For example, what is the user of this feature trying to accomplish? What information do you need from the user and what result do you produce from that information?

Edited 4 Years Ago by deceptikon

But should'nt I be able to use the buttons i have? im thinking like

if (btnStop.Text == "stop")
{ 
    //do this
}
if (btnStop.Text == "go")
{
    //do this
}

so i dont have to make a new button for everything if i can call them like

private void dostuff_Click(object sender, EventArgs e)
    {
    //press this button to start the program
    int value;
    //code code "how old are you? press button 1 or 10"
    //and then you press one button and i get 1 or 10 return
    //so i can further use it with my local variable
    //so i dont have to make an global one
    1.text="1";
    10.text="go";
    if(1.click)
    {
        value=1;
    }
    if(10.click)
    {
        value=10;
    }

    }
    private void 1_Click(object sender, EventArgs e)
    {
        if(1.text == "1")
        {
            return 1;
        }
        if(1.text =="go")
        {
            //someting else
        }
    }
    private void 10_Click(object sender, EventArgs e)
    {
        if(10.text == "10")
        {
            return 10;
        }
        if(10.text =="under")
        {
            //someting else
        }   

    }

i dont know something like this exists?

It could probably exist but I dont see the logic behind the three buttons as there is no way apart from using a modal popup to force someone to click x or y button before proceeding. Hence the point that the button is modal.

Because with your method they can click the doStuff button without clicking either other one. The doStuff button can then not force the clicking of either of the other buttons, it is still down to the users choice unless you lock them out using a modal form.

Feel free to correct me if im wrong Deceptikon.

hmmm yes maybe you are right is that like the "are you sure?" question many programs have?
how do i make on of thoose or what is the name so i can look them up some more :)

Yup exactly like the are you sure buttons, it forces a response.

try googling "custom modal forms c#"

Edited 4 Years Ago by Mike Askew

This question has already been answered. Start a new discussion instead.