Access dialog results from the parent form in c#

This is something very important for a developers who is migrating from VB to .NET. Even though this is explainning using C# it is not much ditingush from VB code.

  • Lets say you are having two Windows forms called Form1 and Form2 in your project. Form1 will be your parent form and Form2 will be the Dialog form.
  • Form1 will have a Command button and a Label control to display the input from the Dialog form(Form2). Dialogform(Form2) will have a textbox and two command buttons.
  • In the Form2 change the text properties of two buttons as OK and CANCEL.
  • Set OK buttons DialogResult property to OK and CANCEL buttons property to Cancel.
  • Set Modifier property of the textBox1 in the Form2 to Public or Internal. This will allow the parent form(In this case form1) to access the text value of the dialog form.
  • Write following code segement on click events of both buttons (Or create one method and change the delegation)
this.Close();
  • In the Form1 Command buttons Click event write the following code
    Form2 nfrm = new Form2();
    if(nfrm.ShowDialog() == DialogResults.OK)
    {
    this.label1.Text = nfrm.textBox1.Text;
    }
    • It is pretty simple and if you have any further quetions, corrections, suggetions please contact me.

    By Kaminda Berugoda

      22 comments:

      Korayem said...

      Awesome! that's the easiest way I've read so far

      Thanks for sharing man

      Anonymous said...

      Wacker, Ihr Gedanke einfach ausgezeichnet viagra preissuche viagra online schweiz [url=http//t7-isis.org]levitra bestellen[/url]

      Anonymous said...

      best web page just for you
      [URL=http://alesse.4t.com/lukol/map.html]Beast online buy lukol online no prescription[/URL] [URL=http://alfacip.8m.com/chromonexin]chromonexin[/URL] [URL=http://alesse.4t.com/chloromint]buy chloromint online[/URL] [URL=http://alkeran.8m.net/ointment]erythromycin ophthalmic ointment[/URL] [URL=http://amaryl.iwarp.com/publix/map.html]Beast online zithromax price walmart or publix[/URL]
      We will not miss you

      Anonymous said...

      usa and canada based free trial dating sites [url=http://loveepicentre.com/]laymen terms carbon dating[/url] gayfetishpersonals http://loveepicentre.com/ canada free online dating

      Anonymous said...

      Howdy,

      I keep coming to this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]You have really contiributed very good info here kaminda.blogspot.com. I am sure due to busy scedules we really do not get time to care about our health. In plain english I must warn you that, you are not serious about your health. Recent Scientific Research displays that nearly 60% of all U.S. adults are either chubby or overweight[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] So if you're one of these individuals, you're not alone. Its true that we all can't be like Brad Pitt, Angelina Jolie, Megan Fox, and have sexy and perfect six pack abs. Now next question is how you can achive quick weight loss? [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss[/url] is really not as tough as you think. Some improvement in of daily activity can help us in losing weight quickly.

      About me: I am blogger of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also health trainer who can help you lose weight quickly. If you do not want to go under difficult training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for effortless weight loss.

      Anonymous said...

      upper limits of vitamin d [url=http://usadrugstoretoday.com/categories/sleeping-aide.htm]sleeping aide[/url] vaginal yeast infection symptoms http://usadrugstoretoday.com/testimonials.htm babies born with herpes http://usadrugstoretoday.com/products/stress-gum.htm
      remedy for rapid heart beat [url=http://usadrugstoretoday.com/categories/gastrointestinale.htm]gastrointestinale[/url] us health works [url=http://usadrugstoretoday.com/products/exelon.htm]cartoons doing drugs[/url]

      Anonymous said...

      military health system data [url=http://usadrugstoretoday.com/products/kamasutra-intensity-condoms.htm]kamasutra intensity condoms[/url] greyhound health and welfare program ohio state university http://usadrugstoretoday.com/products/retin-a-0-05-.htm public health qualitative quantitative reseach health hiv http://usadrugstoretoday.com/categories/antibiotici.htm
      sample hospital infection control program [url=http://usadrugstoretoday.com/products/diclofenac-gel.htm]diclofenac gel[/url] william jenning bryan dorn medical center [url=http://usadrugstoretoday.com/products/imitrex.htm]plan b pill faq[/url]

      Anonymous said...

      what is emotional stress disorder [url=http://usadrugstoretoday.com/products/stress-relief.htm]stress relief[/url] names of prescription iron vitamins http://usadrugstoretoday.com/products/relafen.htm history on medical terminology http://usadrugstoretoday.com/products/revatio.htm
      bloodwork blood test normal range cholesterol sugar [url=http://usadrugstoretoday.com/products/imodium.htm]imodium[/url] herbal brazilian diet pill [url=http://usadrugstoretoday.com/products/zoloft.htm]pet doctor dog penis stuck[/url]

      Anonymous said...

      human genetic disorder [url=http://usadrugstoretoday.com/products/acomplia.htm]acomplia[/url] naturist penis aesthetics cosmetics http://usadrugstoretoday.com/products/yasmin.htm kroger hwy 6 pharmacy http://usadrugstoretoday.com/products/cardura.htm
      enlarged heart and water in the lungs after car accident [url=http://usadrugstoretoday.com/categories/arthrite.htm]arthrite[/url] songs that tell you not to do drugs [url=http://usadrugstoretoday.com/categories/antivirale.htm]paulie the penis[/url]

      Anonymous said...

      http://meen.in/exelon
      [url=http://meen.in/clarinex/clarinex-pseduoephedrine-togehter]drug free poster contests[/url] pills viagra [url=http://meen.in/cardizem/atenolol-compred-to-cardizem-for-irregular-heartbeat]atenolol compred to cardizem for irregular heartbeat[/url]
      mexican drug cartels http://meen.in/cleocin/cleocin-dental
      [url=http://meen.in/esomeprazole/proton-pump-inhibitors-lansoprazole-omeprazole-esomeprazole]find location for pharmacy technician certification test[/url] supreme court the order dismissing on drugs [url=http://meen.in/cialis/cialis-levitra-vs]cialis levitra vs[/url]
      heart rythym drugs http://meen.in/evista/evista-drug-leg-cramp
      [url=http://meen.in/fda]pravastatin drugs[/url] drug allergie braclets [url=http://meen.in/cephalexin/how-long-is-cephalexin-good-for]how long is cephalexin good for[/url] teens hooked on drugs [url=http://meen.in/erections/plaster-cast-erections]plaster cast erections[/url]

      Anonymous said...

      mercedes run flat tires http://automotoportal.in/scooter/la-radio-sullo-scooter automobile towing
      [url=http://automotoportal.in/saleen/saleen-sc331]performance air cleaner dodge truck[/url] midnight clup street racing cheats [url=http://automotoportal.in/volvo/truck-spares-volvo]truck spares volvo[/url]
      dealers auto prices http://automotoportal.in/racing/donahoe-racing-sway-bar
      [url=http://automotoportal.in/motor-co]volkswagen diesels for sale[/url] face recognition system hardware for automobile [url=http://automotoportal.in/mini/mini-atv-3-bolt-pattern]mini atv 3 bolt pattern[/url]
      auto racing news http://automotoportal.in/saleen/saleen-rangers
      [url=http://automotoportal.in/rover/rover-car-parts-uk]carl casper custom auto show[/url] hoffman auto rochester ny [url=http://automotoportal.in/rally/motorcycle-rally-louisiana]motorcycle rally louisiana[/url]

      Anonymous said...

      sag harbor fashions http://topcitystyle.com/casual-page8.html furniture designer evans [url=http://topcitystyle.com/-shirts-with-colar-category22.html]elderly active fashion[/url] rico puhlmann a fashion legacy
      http://topcitystyle.com/trussardi-long-sleeve-tops-brand11.html rss chanel for psp [url=http://topcitystyle.com/bordo-women-s-tops-color140.html]designer wallpaper[/url]

      Anonymous said...

      hemp shoes http://topcitystyle.com/men-underwear-page3.html clothes dryer [url=http://topcitystyle.com/shoes-roberto-cavalli-category12.html]fashion fabric[/url] kids shoes with wheels
      http://topcitystyle.com/armani-page9.html magazine spring fashion ecko show model girls runway red clothing [url=http://topcitystyle.com/?action=products&product_id=1823]inexpensive shoes alderwood lynnwood wash[/url]

      Anonymous said...

      treo 650 t mobile internet connection http://www.orderphonetoday.com/v51-quad-band-dual-card-with-java-unlocked-cell--item50.html mobile aerial base [url=http://www.orderphonetoday.com/changjiang-w001-quad-band-dual-card-with-wifi--item32.html]timeline of mobile phone[/url] boost mobile cell

      Anonymous said...

      movie stills of blazing saddles [url=http://worldmovs.co.cc/full_version-taxi-driver/16729database/]Taxi Driver[/url] talking heads song from movie wall street [url=http://worldmovs.co.cc/full_version-harold---kumar-go-to-white-castle--extreme-unrated-/4611database/]Harold & Kumar Go To White Castle (Extreme Unrated)[/url]
      real genius the movie [url=http://full-length-movies.com/dvd-quality-movie-graduation/3256database/]Graduation[/url] watch the doors movie online [url=http://full-length-movies.com/dvd-quality-movie-historia-de-un-secuestro/7525database/]Historia De Un Secuestro[/url]
      hook movie script [url=http://full-length-movies.com/dvd-quality-movie-sweeney-todd-the-demon-barber-of-fleet-street/9806database/]Sweeney Todd The Demon Barber Of Fleet Street[/url] free nude alternative girl movie dump [url=http://full-length-movies.com/dvd-quality-movie-man-from-utah/30055database/]Man From Utah[/url]
      bijou phillips movie stills getting fucked [url=http://full-length-movies.com/dvd-quality-movie-bodybuilding---larry-scott---life-in/18587database/]Bodybuilding - Larry Scott - Life In[/url] fuck movie samples [url=http://full-length-movies.com/dvd-quality-movie-the-philadelphia-experiment/25042database/]The Philadelphia Experiment[/url]

      Anonymous said...

      rice grain shaped bumps on penis [url=http://usadrugstoretoday.com/products/phosphatidylserine.htm]phosphatidylserine[/url] yeast infection towel http://usadrugstoretoday.com/categories/skin-care.htm
      lapeer county public health department [url=http://usadrugstoretoday.com/products/parlodel.htm]parlodel[/url] zoloft withdrawal information [url=http://usadrugstoretoday.com/products/brand-cialis.htm ]center for mental health noblesville [/url] how to treat infections from phimosis
      medical cause for spot on lung [url=http://usadrugstoretoday.com/products/cytotec.htm]cytotec[/url] over the counter diabetes preparations http://usadrugstoretoday.com/products/actos.htm
      innocent blood dvd cover [url=http://usadrugstoretoday.com/products/remeron.htm]remeron[/url] sherborn board of health [url=http://usadrugstoretoday.com/products/lithium-carbonate.htm ]massachusetts department of public health org chart [/url] beaded necklaces medical id

      Anonymous said...

      neolithic era diet [url=http://usadrugstoretoday.com/products/tetracycline.htm]tetracycline[/url] what is text enhancement http://usadrugstoretoday.com/products/hoodia-weight-loss-gum.htm
      delaware division of public health [url=http://usadrugstoretoday.com/products/avandia.htm]avandia[/url] urinary infection from diarreha [url=http://usadrugstoretoday.com/products/avandia.htm ]medical teams international [/url] heart crafts
      instructions on how to make a heart model [url=http://usadrugstoretoday.com/products/cleocin.htm]cleocin[/url] quad smoke detector http://usadrugstoretoday.com/products/aciclovir.htm
      journal of public health [url=http://usadrugstoretoday.com/products/dulcolax.htm]dulcolax[/url] pictures graphs anxiety disorders [url=http://usadrugstoretoday.com/products/karela.htm ]lyrics take my heart take my heart [/url] calcium definicency

      Anonymous said...

      stride rite shoes http://luxefashion.us/-one-ply-windbreaker-jackets-on-sale-category26.html buy new balance shoes [url=http://luxefashion.us/black-red-roberto-cavalli-color15.html]in memory of lauren n zinsavage[/url] mens euro punk shoes
      http://luxefashion.us/red-black-women-color39.html lauren bergfeld bio [url=http://luxefashion.us/black-silver-shoes-color118.html]designer watches[/url]

      Anonymous said...

      batman meets the joker http://wqm.in/lottery_state-of-missouri-lottery how to run a basket bingo
      [url=http://wqm.in/lottery_wheel-4-numbers-lottery-systems]montecito casino chip card display[/url] win lottery 4 [url=http://wqm.in/bingo_charitible-bingo-in-maine]charitible bingo in maine[/url]
      bingo long and the traveling allstars the play http://wqm.in/online-casino_kansas-concert-tics-buffalo-run-casino-miami-ok
      [url=http://wqm.in/joker_steve-miller-joker-lyrics-alternate]blackjack learn play free casino game[/url] keno brother show [url=http://wqm.in/online-casino_online-blackjack-online-casino-games]online blackjack online casino games[/url]
      gambling pittsburgh pa http://wqm.in/jackpot_lottery-jackpot-payouts gordon miller betting shop [url=http://wqm.in/lottery_once-spanish-lottery]once spanish lottery[/url]

      Anonymous said...

      makutu of mrs jones nz movie [url=http://moviestrawberry.com/films/film_terror_train/]terror train[/url] where to find the movie how high http://moviestrawberry.com/countries/?page=125 get free custom effect for windows movie maker
      pathfind movie info [url=http://moviestrawberry.com/films/film_when_worlds_collide/]when worlds collide[/url] blair witch movie http://moviestrawberry.com/films/film_mabels_strange_predicament/ gandhi movie summary
      cum movie free [url=http://moviestrawberry.com/films/film_lend_a_paw/]lend a paw[/url] movie trailer checks
      porn movie about a catholic all girls school [url=http://moviestrawberry.com/films/film_real_time_with_bill_maher/]real time with bill maher[/url] upload sex movie http://moviestrawberry.com/films/film_the_grass_harp/ indie movie theater mn
      movie the double mcguffin [url=http://moviestrawberry.com/films/film_murder_party/]murder party[/url] movie quotes scent of a woman http://moviestrawberry.com/films/film_love_s_unending_legacy/ lisa de leeuw movie in which she is only

      Anonymous said...

      how to make your own porn movie [url=http://moviestrawberry.com/films/film_shoot_on_sight/]shoot on sight[/url] movie about mad computer http://moviestrawberry.com/films/film_pineapple_express/ hairspray movie clips
      p2 download movie trailer [url=http://moviestrawberry.com/films/film_gym_teacher_the_movie/]gym teacher the movie[/url] movie joe future america idiots http://moviestrawberry.com/films/film_taken_in_broad_daylight/ star trek6 movie
      b western movie posters [url=http://moviestrawberry.com/films/film_if_i_had_known_i_was_a_genius/]if i had known i was a genius[/url] master kims gansta movie
      sienna miller in new movie [url=http://moviestrawberry.com/films/film_withnail_i/]withnail i[/url] jawbreaker movie http://moviestrawberry.com/films/film_unhook_the_stars/ movie camera operation
      free dad daughter movie clips [url=http://moviestrawberry.com/films/film_the_witches_hammer/]the witches hammer[/url] inuyasha movie 1 http://moviestrawberry.com/films/film_sorry_wrong_number/ fucking teen free movie

      Anonymous said...

      Hi,

      I begin on internet with a directory

       
      Blog Directory - OnToplist.com