TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
jjanos_
NA
2
0
Dataset and multiple forms problem
Jan 22 2005 1:16 PM
I'm really stuck with this problem and I think it's quite simple but my knowledge of c# just in't enough, so any help wolud be appriciated. I have a class (called broker) that contains the dataset and methods to manipulate the data in the dataset. It looks something like this: public class Broker { public MainDataSet ds=null; public Broker() { ds=new MainDataSet(); } public void FillDataSet() { //Do something it's not important what } } Next I have a form (called maniform) that uses methods from broker class. Something like this (just the stuff important for my problem): public class MainForm : System.Windows.Forms.Form { public MainForm() { InitializeComponent(); b=new Broker(); } public Broker b=null; private void Form1_Load(object sender, System.EventArgs e) { b.FillDtatSet(); } private void Something() { //Do something } } And in the end I have another form called modform that contains a combobox. Combobox has an on change event that needs to call a method from the mainform. I tried something like this: public void ReturnNewIndex(object sender, System.EventArgs e) { MainForm mfrm=new MainForm(); int index=NameCombo.SelectedIndex; mfrm.Something(index); } This is the problem: if I create instance of the mainform (MainForm mfrm=new MainForm()) in the modform dataset is recreated (Mainform new--> mainform calls constructor and creates new broker instance--> new broker instance calls its broker and recreates the dataset and the dataset is now empty). How to do this so that the dataset is not recreated and I can access methods from the main form? Please help I don't know who to ask and I have only a few days to solve the problem.
Reply
Answers (
1
)
Forms with no title bar
Creating Custom DataGrid Column