By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,566 Members | 1,820 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,566 IT Pros & Developers. It's quick & easy.

datagrid crashes program when loading on the fly

P: n/a
here are the lines of code that I've tried. All crash the program

shownVals is a string array
data is my datatable

//problem code #1

loop here{
((Form1)NewsMyWay.Form1.ActiveForm).data.Rows.Add( shownVals);
}

//problem code #2

((Form1)NewsMyWay.Form1.ActiveForm).data.BeginLoad Data();

loop here{

((Form1)NewsMyWay.Form1.ActiveForm).data.LoadDataR ow(shownVals,false);

}

((Form1)NewsMyWay.Form1.ActiveForm).data.EndLoadDa ta();

//problem code #3

loop here{
((Form1)NewsMyWay.Form1.ActiveForm).data.BeginLoad Data();
((Form1)NewsMyWay.Form1.ActiveForm).data.LoadDataR ow(shownVals,false);
((Form1)NewsMyWay.Form1.ActiveForm).data.EndLoadDa ta();
}

I'm pulling data from the internet and trying to put it into my
dataGrid on the fly but I always recieve a

System.NullReferenceException

when the grid is populating or a few seconds after it has finished.
I've also tried to throw in

((Form1)NewsMyWay.Form1.ActiveForm).data.AcceptCha nges();

in various spots in my code but that does nothing. When I save the
downloaded data to a txt file I can import the data to the grid fine.
Unless there is too much data, that also causes a crash but is another
issue. I'm at a loss :/
Any suggestions are much appreciated. Thank you

Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You use a "working" thread to load the data in the dataset?

Try to use the following piece of code:

Form1 f=(Form1)NewsMyWay.Form1.ActiveForm;
f.Invoke(f.data.Rows.Add,shownVals);
"polarz" <po****@hotmail.com> schrieb im Newsbeitrag
news:t3********************************@4ax.com...
here are the lines of code that I've tried. All crash the program

shownVals is a string array
data is my datatable

//problem code #1

loop here{
((Form1)NewsMyWay.Form1.ActiveForm).data.Rows.Add( shownVals);
}

//problem code #2

((Form1)NewsMyWay.Form1.ActiveForm).data.BeginLoad Data();

loop here{

((Form1)NewsMyWay.Form1.ActiveForm).data.LoadDataR ow(shownVals,false);

}

((Form1)NewsMyWay.Form1.ActiveForm).data.EndLoadDa ta();

//problem code #3

loop here{
((Form1)NewsMyWay.Form1.ActiveForm).data.BeginLoad Data();
((Form1)NewsMyWay.Form1.ActiveForm).data.LoadDataR ow(shownVals,false);
((Form1)NewsMyWay.Form1.ActiveForm).data.EndLoadDa ta();
}

I'm pulling data from the internet and trying to put it into my
dataGrid on the fly but I always recieve a

System.NullReferenceException

when the grid is populating or a few seconds after it has finished.
I've also tried to throw in

((Form1)NewsMyWay.Form1.ActiveForm).data.AcceptCha nges();

in various spots in my code but that does nothing. When I save the
downloaded data to a txt file I can import the data to the grid fine.
Unless there is too much data, that also causes a crash but is another
issue. I'm at a loss :/
Any suggestions are much appreciated. Thank you

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.