c# so confused passing data

Discussion in 'Software' started by mastermosley, Sep 30, 2010.

  1. mastermosley

    mastermosley Sergeant

    I just jumped back into program from a few months I've seemed to already forgotten some of the basics. I have my main form, I hit a button opens up a little tool window that asks for some information, the form is then closed and the textbox string gets put into my listbox on the main form. I cant remember how to send the data from another form without making a new form.

    I'm reading these tutorials that say the four different ways: constructor, objects, properties, and delegates but it seems to be the opposite way I need it because when the data is sent back my main form is already opened, I dont need to make a new one... :confused
     
  2. Kodo

    Kodo SNATCHSQUATCH

    there are a few ways to do this. Probably the cleanest way is to use an event to capture the data so that it's not referenced by anything in either form. The event can pass an event argument that holds the data. The main form listens for the other "Tool form's" event to fire by subscribing to the tools forms' event. When data is submitted via the click on the other form, fire the event and handle it in the main form.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds