c# - Getting data from another form into dataGridView -


i working on account generator , need making accounts appear datagridview in form. code right now. don't know how can put accounts datagridview.

this form have:

private void button4_click(object sender, eventargs e)     {         string email = richtextbox2.text;         string password = richtextbox1.text;         (var currentaccount = 0; currentaccount < (int32.tryparse(out)).richtextbox4.text; currentaccount++)         {         }          list<string> firstnames = new list<string>();         firstnames.add("james");         firstnames.add("jakob");         firstnames.add("jacob");         firstnames.add("jonathan");         firstnames.add("albert");         firstnames.add("calvin");         firstnames.add("kyle");         firstnames.add("christopher");         firstnames.add("jeremy");         firstnames.add("ari");         firstnames.add("maximus");         firstnames.add("jerry");         firstnames.add("eric");         firstnames.add("trey");         firstnames.add("brenden");         firstnames.add("sean");         firstnames.add("timmothy");         firstnames.add("harris");         firstnames.add("matthew");         firstnames.add("michael");         firstnames.add("ching");         firstnames.add("alexander");          random rand = new random();         int x = rand.next(0, firstnames.count);          list<string> lastnames = new list<string>();         lastnames.add("hampton");         lastnames.add("green");         lastnames.add("doe");         lastnames.add("ching");         lastnames.add("chong");         lastnames.add("albertson");         lastnames.add("ringel");         lastnames.add("alerstein");         lastnames.add("zion");         lastnames.add("stein");         lastnames.add("stine");         lastnames.add("elzed");         lastnames.add("jackson");         lastnames.add("cooperberg");         lastnames.add("charman");         lastnames.add("calberg");         lastnames.add("dorfmanberg");          int y = rand.next(0, lastnames.count);          list<string> passwords = new list<string>();         passwords.add("richtextbox1_textchanged");          list<string> screenname = new list<string>();         screenname.add("");          list<string> emails = new list<string>();         emails.add("richtextbox2_textchanged+1209943");         emails.add("richtextbox2_textchanged+16329943");         emails.add("richtextbox2_textchanged+56329943");         emails.add("richtextbox2_textchanged+9943");         emails.add("richtextbox2_textchanged+123456329943");         emails.add("richtextbox2_textchanged+156329943");         emails.add("richtextbox2_textchanged+1239943");         emails.add("richtextbox2_textchanged+123456329943");         emails.add("richtextbox2_textchanged+1234563292943");         emails.add("richtextbox2_textchanged+12345603");         emails.add("richtextbox2_textchanged+1234563299");         emails.add("richtextbox2_textchanged+13001");         emails.add("richtextbox2_textchanged+12990-3");         emails.add("richtextbox2_textchanged+99103z");         emails.add("richtextbox2_textchanged+1x3");         emails.add("richtextbox2_textchanged+1623bdsjaw");         emails.add("richtextbox2_textchanged+99jsd943");         emails.add("richtextbox2_textchanged+12345938urfv3");         emails.add("richtextbox2_textchanged+ejfj9943");         emails.add("richtextbox2_textchanged+1234rmd43");         emails.add("richtextbox2_textchanged+dmmd29943");         emails.add("richtextbox2_textchanged+123456kiuj943");         emails.add("richtextbox2_textchanged+12i8839291");         emails.add("richtextbox2_textchanged+123bfbdba3");         emails.add("richtextbox2_textchanged+123absna43");         emails.add("richtextbox2_textchanged+1234ababsba9943");         emails.add("richtextbox2_textchanged+1asa943");         emails.add("richtextbox2_textchanged+989283");         emails.add("richtextbox2_textchanged+1234jfn9943");         emails.add("richtextbox2_textchanged+kd13jd23");         emails.add("richtextbox2_textchanged+938478du");           list<string> birthmonth = new list<string>();         birthmonth.add("1");         birthmonth.add("2");         birthmonth.add("3");         birthmonth.add("4");         birthmonth.add("5");         birthmonth.add("6");         birthmonth.add("7");         birthmonth.add("8");         birthmonth.add("9");         birthmonth.add("10");         birthmonth.add("11");         birthmonth.add("12");         int z = rand.next(0, birthmonth.count);          list<string> birthday = new list<string>();         birthday.add("13");         birthday.add("10");         birthday.add("9");         birthday.add("7");         birthday.add("30");         birthday.add("20");         birthday.add("21");         birthday.add("3");         birthday.add("2");         birthday.add("1");         birthday.add("19");         birthday.add("18");         birthday.add("15");         birthday.add("11");         birthday.add("22");         birthday.add("26");         birthday.add("27");         birthday.add("29");         int = rand.next(0, birthday.count);          list<string> birthyear = new list<string>();         birthyear.add("1985");         birthyear.add("1986");         birthyear.add("1987");         birthyear.add("1988");         birthyear.add("1989");         birthyear.add("1990");         birthyear.add("1991");         birthyear.add("1992");         birthyear.add("1993");         birthyear.add("1994");         birthyear.add("1995");         birthyear.add("1984");         birthyear.add("1983");         birthyear.add("1982");         birthyear.add("1981");         int b = rand.next(0, birthyear.count);          list<string> postalcode = new list<string>();         postalcode.add("richtextbox5_textchanged");          list<string> gender = new list<string>();         gender.add("male");          string first = firstnames[x];         string last = lastnames[y];          combobox1.findstringexact("nike_us"); webbrowser1.document.getelementbyid("exp-register-firstname").setattribute("value", "firstnames");         combobox1.findstringexact("nike_us"); webbrowser1.document.getelementbyid("exp-register-lastname").setattribute("value", "lastnames");         combobox1.findstringexact("nike_us"); webbrowser1.document.getelementbyid("exp-register-email").setattribute("value", "emails");         combobox1.findstringexact("nike_us"); webbrowser1.document.getelementbyid("exp-register-password").setattribute("value", "passwords");         combobox1.findstringexact("nike_us"); webbrowser1.document.getelementbyid("exp-register-passwordconfirm").setattribute("value", "passwords");         combobox1.findstringexact("nike_us"); webbrowser1.document.getelementbyid("exp-register-screenname").setattribute("value", "screenname");         combobox1.findstringexact("nike_us"); webbrowser1.document.getelementbyid("exp-register-dob-month").setattribute("value", "birthmonth");         combobox1.findstringexact("nike_us"); webbrowser1.document.getelementbyid("exp-register-dob-day").setattribute("value", "birthday");         combobox1.findstringexact("nike_us"); webbrowser1.document.getelementbyid("exp-register-dob-year").setattribute("value", "birthyear");         combobox1.findstringexact("nike_us"); webbrowser1.document.getelementbyid("exp-register-postalcode").setattribute("value", "postalcode");         combobox1.findstringexact("nike_us"); webbrowser1.document.getelementbyid("exp-register-gender-male").setattribute("value", "gender");         combobox1.findstringexact("nike_us"); webbrowser1.document.getelementbyid("sign_up").invokemember("click");         (int = 1; <= 5; i++)         {             console.writeline(i);         } 

create new form constructor child form , in child form setup properties needs passed. below shows overload new constructor 1 parameter , needed repeat pattern.

please note there other methods, 1 of them. second note: used listbox keep simple , realize have datagridview.

main form

public partial class form1 : form {     public form1()     {         initializecomponent();     }     private void button1_click(object sender, eventargs e)     {         list<string> firstnames = new list<string>();         firstnames.add("james");         firstnames.add("jakob");         firstnames.add("jacob");         firstnames.add("jonathan");         firstnames.add("albert");         firstnames.add("calvin");         firstnames.add("kyle");         firstnames.add("christopher");         firstnames.add("jeremy");         firstnames.add("ari");         firstnames.add("maximus");         firstnames.add("jerry");         firstnames.add("eric");         firstnames.add("trey");         firstnames.add("brenden");         firstnames.add("sean");         firstnames.add("timmothy");         firstnames.add("harris");         firstnames.add("matthew");         firstnames.add("michael");         firstnames.add("ching");         firstnames.add("alexander");          form2 f = new form2(firstnames);          try         {             f.showdialog();         }                 {             f.dispose();         }     }  } 

child form listbox, property first names list.

public partial class form2 : form {     public list<string> firstnames { get; set; }     public form2()     {         initializecomponent();     }     public form2(list<string> firstnames)     {         initializecomponent();         this.firstnames = firstnames;         this.shown += form2_shown;     }      private void form2_shown(object sender, eventargs e)     {         listbox1.datasource = this.firstnames;     } } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -