anoop
anoop

Reputation:

What is the maximum record count for a DataGrid in VB.NET?

What is the maximum record count for a DataGrid in VB.NET? Is there any limit?

Upvotes: 0

Views: 9138

Answers (4)

shahkalpesh
shahkalpesh

Reputation: 33474

Apart from Integer.MaxValue, I guess it depends on the memory available to the application & already used.

Why are you thinking of filling the grid with all rows at once?
It doesn't make sense showing users all the records.

Upvotes: 0

Jim H.
Jim H.

Reputation: 5579

The Count property of the DataGridView.Rows collection is an Integer, so the normal range for 4-byte signed integers should apply as an effective limit: 0 to 2,147,483,647

As to what the Rows collection can actually hold, I'm not sure... it would depend on what your application is actually doing.

Upvotes: 0

Joel Coehoorn
Joel Coehoorn

Reputation: 416029

I'm not aware of any hard limit outside the physical limitations of available memory or perhaps Integer.MaxValue. I wouldn't be too surprised if there is, though.

What's more important is that a datagrid is a visual construct shown to real users. Users won't much appreciate a grid with 1000 items it, let alone 100,000+ (which I have seen before).

The point is that rather than worrying about the maximum records you can stuff in there, you're better off implementing paging or a better search mechanism.

Upvotes: 1

JaredPar
JaredPar

Reputation: 755121

There is no explicit limitation in a DataGrid.

However it is constrained by both it's internal data structures which tend to count rows in terms of Integer. This means the hard limit is Integer.MaxValue

On a 32 bit system though, you will hit problems long before you hit Integer.MaxValue rows. Every item added to the DataGrid has a certain amount of overhead. If each item only has 4 bytes of overhead, you will max out at Integer.MaxValue / 4. This is really a simplistic view of the problem though because it doesn't take into account other controls, internal WinForms resources, etc ...

How many records are you thinking of adding?

Upvotes: 3

Related Questions