c# - Dynamic Windows Form Initialization -


i trying write program (console initialized) in c# dynamically initializes set of windows forms.

it's tournament program allows user manage multiple stations @ once.

so, best i've come like, say, user wants manage 3 stations.

tournamentform[] t = new tournamentform[3];  void starttournament() {     (int count = 0; count < t.length; count++)     {         t[count] = new tournamentform();         t[count].show();     } } 

the inherent problem approach @ end of each loop, form closed.

is there means of dynamically initializing windows forms, or have long code maximum number of windows instances?


hmm... may have had idea using recursion while writing this. still posting question in case there's better answer.


so have been using forum thought board... shoot me. prefer holes shot in ideas on.

@bas here code compiles

namespace tournament_2._1 {     class program     {         static mainwindow[] test = new mainwindow[2];          static void main(string[] args)         {             starttournament();         }          private static void starttournament()         {             (int count = 0; count < test.length; count++)             {                 test[count] = new mainwindow();                  test[count].show();             }          }     } } 

what missing while loop in main() method (even while stepping through each line) windows being closed @ end of main() method, not @ end of each loop.

to try manage have tried couple ways of pausing console, , none have been allowing focus on forms.

same problem, different location.

is "windows forms application" project?

in "program.cs":

    [stathread]     static void main()     {         application.enablevisualstyles();         application.setcompatibletextrenderingdefault(false);         application.run(new mainform());     } 

add button "btnstart" on mainform.

for button, add event handler on click.

in mainform.cs:

public partial class mainform : form {     public mainform()     {         initializecomponent();     }      private void btnstart_click(object sender, eventargs e)     {         form[] t = new form[3];          (int count = 0; count < t.length; count++)         {             t[count] = new form();             t[count].show();         }     } } 

this way, forms not close after loop.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -