I have a visual studio 2005 form application. I also have created a header and source file with gets and sets and private variables for some of the data. How do I pass this data between forms? Ive looked at delegates but am having trouble understanding, is there another way, or some simple sample code on delegates if that is the only way? Thanks.

Edward prefers to pass data between forms using properties. Delegates work more with behavior than data, so they probably aren't a good match for what you want to do, which is something like this very incomplete example:

ref class Form1: Form {
  int _data;
public:
  Form1()
  {
    _data = 123;
  }

  void Run()
  {
    Form2^ form = gcnew Form2();

    form->Data = _data;
    form->Run();
  }
};

ref class Form2: Form {
  int _data;
public:
  property int Data {
    int get() { return _data; }
    void set(int value) { _data = value; }
  }

  void Run()
  {
    MessageBox::Show(String::Format("{0}", _data));
  }
};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.