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

Datagrid crashes program, when input data is too large

P: n/a
I've written a program that pulls data from the internet and puts it
into a datagrid. When the number of rows reaches a certain point my
program freezes.

Is there a limit to the number of rows you can add? If so, is there a
way to get around this?

Any suggestions are much appreciated. Thanks.
Nov 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi,

Are you using threading by any chance?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"polarz" <po****@hotmail.com> wrote in message
news:d1********************************@4ax.com...
I've written a program that pulls data from the internet and puts it
into a datagrid. When the number of rows reaches a certain point my
program freezes.

Is there a limit to the number of rows you can add? If so, is there a
way to get around this?

Any suggestions are much appreciated. Thanks.

Nov 15 '05 #2

P: n/a
Hi Miha, thanks for the reply. Yes I am using threading. I've tried to
base my code off of this

http://msdn.microsoft.com/library/de...ms06112002.asp

This is my first attempt at using threading so I may be doing
something wrong. Everything seems to work perfect until I get a lot of
data. The most rows I've added is several hundred, I'm not sure of an
exact number. I haven't done anything with the a Cancel button, but
some of that code is left in. My threading code is posted below. Any
suggestions are much appreciated. Thanks
Progress p = new Progress();
p.popData(shownVals, numArticles);

public class Progress : System.Windows.Forms.Form
{
public Progress()
{}
enum CalcState
{
Pending,
Calculating,
Canceled,
}

Form1 f=(Form1)UpdateMyWay.Form1.ActiveForm;
CalcState state = CalcState.Pending;

class ShowProgressArgs : EventArgs
{
public string[] progressArr;
public bool Cancel;
public string numArticles;

public ShowProgressArgs(string[] progressArr,
string numArticles)
{
this.numArticles = numArticles;
this.progressArr = progressArr;
}

}

delegate void ShowProgressHandler(object sender, ShowProgressArgs e);

void ShowProgress(object sender, ShowProgressArgs e)
{
// Make sure we're on the right thread
if( this.InvokeRequired == false )
{
// Check for Cancel
e.Cancel = (state == CalcState.Canceled);
Convert.ToBoolean(e.progressArr[0]);
f.textBox1.Text= e.numArticles;
f.textBox1.Update();
f.data.Rows.Add(e.progressArr);
f.myDataGrid.Update();

// Check for completion
if( e.Cancel)
{
state = CalcState.Pending;
}
}
// Transfer control to correct thread
else
{
ShowProgressHandler
showProgress = new ShowProgressHandler(ShowProgress);
Invoke(showProgress, new object[] { sender, e});
}
}

public void popData(string[] sData, string nArticles)
{
object sender = System.Threading.Thread.CurrentThread;
ShowProgressArgs e = new ShowProgressArgs(sData, nArticles);

// Show progress (ignoring Cancel so soon)
ShowProgress(sender, e);
}
}

//Thanks Miha ;)
On Sun, 22 Feb 2004 11:31:09 +0100, "Miha Markic [MVP C#]" <miha at
rthand com> wrote:
Hi,

Are you using threading by any chance?


Nov 15 '05 #3

P: n/a
Hi,

There is virtually no limit to the amount of data that can be shown by the datagrid - it's only limited by the amount of memory the client system has. So your issue might be something else...

Regards,
fbhcah
Nov 15 '05 #4

P: n/a
Hi,

The code seems ok at the first glance.
Do you touch (in worker thread) sData after you assign it to grid?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"polarz" <po****@hotmail.com> wrote in message
news:sc********************************@4ax.com...
Hi Miha, thanks for the reply. Yes I am using threading. I've tried to
base my code off of this

http://msdn.microsoft.com/library/de...ms06112002.asp
This is my first attempt at using threading so I may be doing
something wrong. Everything seems to work perfect until I get a lot of
data. The most rows I've added is several hundred, I'm not sure of an
exact number. I haven't done anything with the a Cancel button, but
some of that code is left in. My threading code is posted below. Any
suggestions are much appreciated. Thanks
Progress p = new Progress();
p.popData(shownVals, numArticles);

public class Progress : System.Windows.Forms.Form
{
public Progress()
{}
enum CalcState
{
Pending,
Calculating,
Canceled,
}

Form1 f=(Form1)UpdateMyWay.Form1.ActiveForm;
CalcState state = CalcState.Pending;

class ShowProgressArgs : EventArgs
{
public string[] progressArr;
public bool Cancel;
public string numArticles;

public ShowProgressArgs(string[] progressArr,
string numArticles)
{
this.numArticles = numArticles;
this.progressArr = progressArr;
}

}

delegate void ShowProgressHandler(object sender, ShowProgressArgs e);

void ShowProgress(object sender, ShowProgressArgs e)
{
// Make sure we're on the right thread
if( this.InvokeRequired == false )
{
// Check for Cancel
e.Cancel = (state == CalcState.Canceled);
Convert.ToBoolean(e.progressArr[0]);
f.textBox1.Text= e.numArticles;
f.textBox1.Update();
f.data.Rows.Add(e.progressArr);
f.myDataGrid.Update();

// Check for completion
if( e.Cancel)
{
state = CalcState.Pending;
}
}
// Transfer control to correct thread
else
{
ShowProgressHandler
showProgress = new ShowProgressHandler(ShowProgress);
Invoke(showProgress, new object[] { sender, e});
}
}

public void popData(string[] sData, string nArticles)
{
object sender = System.Threading.Thread.CurrentThread;
ShowProgressArgs e = new ShowProgressArgs(sData, nArticles);

// Show progress (ignoring Cancel so soon)
ShowProgress(sender, e);
}
}

//Thanks Miha ;)
On Sun, 22 Feb 2004 11:31:09 +0100, "Miha Markic [MVP C#]" <miha at
rthand com> wrote:
Hi,

Are you using threading by any chance?

Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.