0

MSFlexGrid gives this 30006 Error each time it reaches ~350,000 cells.

Error Definition:

Run-time error '30006':

Unable to Allocate Memory For FlexGrid

My Code Sample:

Do While Not rs.EOF
    With MSFlexGrid1
        .Rows = .Rows + 1
        .TextMatrix(i, 1) = rs.Fields("1")    's1
        .TextMatrix(i, 2) = rs.Fields("2")    's2
        .TextMatrix(i, 3) = rs.Fields("3")    'f1
        .TextMatrix(i, 4) = rs.Fields("4")    'gr1
        .TextMatrix(i, 5) = rs.Fields("5")    'gr2
        .TextMatrix(i, 6) = rs.Fields("6")    'gr3
        .TextMatrix(i, 7) = rs.Fields("7")    'gr4
        .TextMatrix(i, 8) = rs.Fields("8")    'gr5
        .TextMatrix(i, 9) = rs.Fields("9")    'gr6
        .TextMatrix(i, 10) = rs.Fields("10")  'gr7
        .TextMatrix(i, 11) = rs.Fields("11")  'gr8
        .TextMatrix(i, 12) = rs.Fields("12")  'c1
        .TextMatrix(i, 13) = rs.Fields("13")  'g1
        .TextMatrix(i, 14) = rs.Fields("14")  's3
        .TextMatrix(i, 15) = rs.Fields("15")  'f2
        .CellAlignment = 4
        .TopRow = .Rows - 1
        .Refresh
    End With
    i = i + 1
    rs.MoveNext
Loop

i need to use at least 600,000 cells in MSFlexGrid, so how can i resolve this?

Community
  • 1
  • 1
Berker Yüceer
  • 7,026
  • 18
  • 68
  • 102
  • 1
    By using another control? You've hit a memory limit for which the only way to avoid is to use less memory. The listview and more modern grid controls allow for virtual lists which leaves the house keeping to your code. Having said that, the normal suggestion is to show less data. The user can't make easy use of 600,000 entries in a list without some form of filtering or paging. – Deanna Sep 25 '12 at 13:24
  • @Deanna i actually were waiting for a trick.. cause ill be the one who uses it. I even made my own search bar for this! its totaly experimental so im not worrying about users. Its more like, have you ever wanna see tons of data on your screen? That is what i want and if MSFlexGrid fails at it surely i would like to use some API's. but i dont wanna loose all my time to understand the API. I need an easy solution for this to keep my project up else i would get bored and leave it to the dumpster. – Berker Yüceer Sep 25 '12 at 14:35
  • There isn't an easier solution. You've hit the limit of that control. Either show less data, or use another control. – Deanna Sep 25 '12 at 15:04
  • @Deanna Well if i cant fill whole data to my flexgrid than i ll reset it and create a background process that fills all data to a txt file. That way i can handle it i guess. – Berker Yüceer Sep 26 '12 at 12:43
  • Erm, how does that help the stated problem? Or are you using the grid to store the data as well as just displaying it? If so, then you should look at decoupling your UI form the backend. – Deanna Sep 26 '12 at 13:04
  • @Deanna it doesnt helps. i can hide couple more controls and show them in tabs when it reaches to the limit but think about how bad it would look. for that reason i decided to show only last piece of data instead all and created a txt file behind to keep the necessary data. so i just sh.ted on it. just to keep UI intact. – Berker Yüceer Sep 26 '12 at 13:49

1 Answers1

0
'I got 15 columns so this makes 21874row * 15column = 328110 cells
'it blows at 21875th row so 328125th cell is not reachable
'for that reason i reset the grid so it keeps 
Do While Not rs.EOF
    With MSFlexGrid1
        If .Rows >= 21874 Then
            .Rows = 2
            .Clear
            i = 1
        End If
        .Rows = .Rows + 1
        .TextMatrix(i, 1) = rs.Fields("1")    's1
        .TextMatrix(i, 2) = rs.Fields("2")    's2
        .TextMatrix(i, 3) = rs.Fields("3")    'f1
        .TextMatrix(i, 4) = rs.Fields("4")    'gr1
        .TextMatrix(i, 5) = rs.Fields("5")    'gr2
        .TextMatrix(i, 6) = rs.Fields("6")    'gr3
        .TextMatrix(i, 7) = rs.Fields("7")    'gr4
        .TextMatrix(i, 8) = rs.Fields("8")    'gr5
        .TextMatrix(i, 9) = rs.Fields("9")    'gr6
        .TextMatrix(i, 10) = rs.Fields("10")  'gr7
        .TextMatrix(i, 11) = rs.Fields("11")  'gr8
        .TextMatrix(i, 12) = rs.Fields("12")  'c1
        .TextMatrix(i, 13) = rs.Fields("13")  'g1
        .TextMatrix(i, 14) = rs.Fields("14")  's3
        .TextMatrix(i, 15) = rs.Fields("15")  'f2
        .CellAlignment = 4
        .TopRow = .Rows - 1
        .Refresh
    End With
    i = i + 1
    rs.MoveNext
Loop
Berker Yüceer
  • 7,026
  • 18
  • 68
  • 102