Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DataSet between Forms

DataSet between Forms

Scheduled Pinned Locked Moved C#
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hxxbin
    wrote on last edited by
    #1

    Hi I got a question, how can I access to a DataSet or any object from another Form in the same project??. I have a main form, (no MDI), and show a dialog, but I wanna that dialog use a Dataset from the main form. Thanks. ---- hxxbin

    C 1 Reply Last reply
    0
    • H hxxbin

      Hi I got a question, how can I access to a DataSet or any object from another Form in the same project??. I have a main form, (no MDI), and show a dialog, but I wanna that dialog use a Dataset from the main form. Thanks. ---- hxxbin

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      If you design your application properly things like datasets won't be controlled by forms so you shouldn't need to pass a dataset between forms. Here is a good place to start: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/DesMVC.asp[^] Also, analysing the way you asked your question ("from another Form in the same project") I have some doubts about your understanding of Object Orientation. So you may like to read also http://www.codeproject.com/useritems/beginneroop.asp[^] which was written with examples in C++ but the concept equally applies to C# Finally, to actually answer your question I have provided a example implementation. In the method in the main form that opens the dialog do something like this:

      DialogForm dlg = new DialogForm();
      dlg.TheDataset = this.myDataset;
      dlg.ShowDialog();

      where: this.myDataset is your dataset and dlg.TheDataset is defined in your Dialog Form's class as

      public Dataset TheDataSet
      {
      set
      {
      this.theDataset = value;
      }
      }

      and that the Dialog Form also has a field defined as: private Dataset theDataset Does this help?


      "You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups