473,806 Members | 2,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid crashes program, when input data is too large

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
4 1897
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.c om...
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
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(shown Vals, numArticles);

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

Form1 f=(Form1)Update MyWay.Form1.Act iveForm;
CalcState state = CalcState.Pendi ng;

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

public ShowProgressArg s(string[] progressArr,
string numArticles)
{
this.numArticle s = numArticles;
this.progressAr r = progressArr;
}

}

delegate void ShowProgressHan dler(object sender, ShowProgressArg s e);

void ShowProgress(ob ject sender, ShowProgressArg s e)
{
// Make sure we're on the right thread
if( this.InvokeRequ ired == false )
{
// Check for Cancel
e.Cancel = (state == CalcState.Cance led);
Convert.ToBoole an(e.progressAr r[0]);
f.textBox1.Text = e.numArticles;
f.textBox1.Upda te();
f.data.Rows.Add (e.progressArr) ;
f.myDataGrid.Up date();

// Check for completion
if( e.Cancel)
{
state = CalcState.Pendi ng;
}
}
// Transfer control to correct thread
else
{
ShowProgressHan dler
showProgress = new ShowProgressHan dler(ShowProgre ss);
Invoke(showProg ress, new object[] { sender, e});
}
}

public void popData(string[] sData, string nArticles)
{
object sender = System.Threadin g.Thread.Curren tThread;
ShowProgressArg s e = new ShowProgressArg s(sData, nArticles);

// Show progress (ignoring Cancel so soon)
ShowProgress(se nder, 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
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
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.c om...
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(shown Vals, numArticles);

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

Form1 f=(Form1)Update MyWay.Form1.Act iveForm;
CalcState state = CalcState.Pendi ng;

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

public ShowProgressArg s(string[] progressArr,
string numArticles)
{
this.numArticle s = numArticles;
this.progressAr r = progressArr;
}

}

delegate void ShowProgressHan dler(object sender, ShowProgressArg s e);

void ShowProgress(ob ject sender, ShowProgressArg s e)
{
// Make sure we're on the right thread
if( this.InvokeRequ ired == false )
{
// Check for Cancel
e.Cancel = (state == CalcState.Cance led);
Convert.ToBoole an(e.progressAr r[0]);
f.textBox1.Text = e.numArticles;
f.textBox1.Upda te();
f.data.Rows.Add (e.progressArr) ;
f.myDataGrid.Up date();

// Check for completion
if( e.Cancel)
{
state = CalcState.Pendi ng;
}
}
// Transfer control to correct thread
else
{
ShowProgressHan dler
showProgress = new ShowProgressHan dler(ShowProgre ss);
Invoke(showProg ress, new object[] { sender, e});
}
}

public void popData(string[] sData, string nArticles)
{
object sender = System.Threadin g.Thread.Curren tThread;
ShowProgressArg s e = new ShowProgressArg s(sData, nArticles);

// Show progress (ignoring Cancel so soon)
ShowProgress(se nder, 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3857
by: greeningster | last post by:
I have written an application in Visual C++ for a customer but it seems to crash randomly. Could anyone give me any help on how I could track this down ? Also, there appears there might be memory leaks too. How can i track these down ?
1
1412
by: polarz | last post by:
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); }
2
1616
by: ddaniel | last post by:
I have read many posts and seen many papers on the different techniques for sort and filtering datagrids. Many do re-queries against the dB ala Fritz Onion. I am trying to leverage the Dataview. The following control simply responds to a sort request and/or a pageing reqeust with an empty table (header only). Any ideas ? Code behind : namespace OakTree.data {
5
2797
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go to the database to get the next page. Is there a way to use the dataset to allow us to read back and forth in it instead of going back to the database to get it? Thanks,
6
4602
by: jason | last post by:
hello everyone, one of my developers is working with a DataGrid component, which uses a DataTable as its DataSource. the DataTable is populated by a method which calls a stored procedure through an SqlCommand object, which accepts two input parameters which affect the query range. the problem she's experiencing is that with all input parameter values,
5
1380
by: Benoit Martin | last post by:
Hello, I am not expecting to get THE fix for my problem but I need help to get started in the right direction In one of my classes, I instantiate an object inherited from the System.Windows.Forms.Form class. Most of the time this works good but every once in a while, the application crashes and goes back to the VS.net or Desktop depending if I'm running from VS or not. I don't get any error message before the crash and the Try Catch...
2
2658
by: Flack | last post by:
I have a DataGrid and a DataTable. When my form loads I create the DataTable with the appropriate columns and use it for the DataGrids.DataSource. Later on in my app, I alter the DataTable: dt.BeginLoadData(); for(int i = 0; i < _movesArrayList.Count; i++) { string columnValues = ((string)_movesArrayList).Split(COL_SEPARATOR); DataRow _moveRow = dt.NewRow();
3
1716
by: kingflux | last post by:
Hello, and thank you in advance for any help you can provide. Each line in our datagrid control contains a product number, description, and a textbox for the user to enter a quantity-to-order. Users enter quantities (not necessarily on every line), click the Next button, and continue. Sometimes users return to a previous page, by clicking the Previous button, and see quantities that they did not enter. More often, users return to a...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10620
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10369
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10372
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.