c# - Connecting choices to buttons -


i want make interactive story in windows form , connect choices buttons. have like...

        richtextbox1.text = "would to...                             1. kill dragon?                             2. run away?                             3. talk dragon."          if ( button choice )         {}          if else ( button choice )          {}          else ( button choice )         {} 

and have 3 buttons on form named 1, 2, 3. how can use these buttons make choices in program?

try this:

public form1() {    initializecomponent();    button1.click += button_click;    button2.click += button_click;    button3.click += button_click; } 

and:

private void button_click(object sender, eventargs e) {     button btn = sender button;     if (btn.name == "button1")     {        // here according to..     }     else if (btn.name == "button2")     {       // here according to..     }         .... } 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -