Heike Posted September 29, 2003 Posted September 29, 2003 I have a datagrid with its DataSource set to a dataset. The first time the user clicks on the button "show" 25 records are read. Now I need the following functionality: If the user scrolls down and the last record is reached, the next 25 records should be read. This is how I tried to do it: Private Sub grdDataGrid_Scroll(...) Handles grdDataGrid.Scroll Dim intShowAnzahl As Integer Try intShowAnzahl = dgcTopLeftVisibleCell.RowNumber + Me.grdDataGrid.VisibleRowCount If intShowAnzahl = intSatzAnzahl Then DataGridLoadNext() End If Catch ex As Exception ErrorMessage(...) End Try End Sub Private Sub DataGridLoadNext(Optional ByVal blnSetPoint As Boolean = False) Dim intNewAnz As Integer Dim intAktAnz As Integer Try If mblnFirst Then mblnFirst = False DataGridLoad() Else If intSatzAnzahl > 0 And intSatzAnzahl < objIBS_Query.lngMaxReadRecord Then blnSatzAnzahlEnde = True End If If blnSatzAnzahlEnde = False Then Me.Cursor = Windows.Forms.Cursors.WaitCursor intAktAnz = Me.BindingContext(Me.DseDataSetPatient1, "KHSPET0").Count intSatzAnzahl = intAktAnz objIBS_Query.DataAdapterFillWaiting(objIBS_Query.dadDataAdapterPatient, Me.DseDataSetPatient1, intSatzAnzahl, CInt(objIBS_Query.lngMaxReadRecord), "KHSPET0") DataGridFormat() If blnSetPoint = True Then If Me.grdDataGrid.RowCount > 0 Then 'hb130103 poiPointInCell00 = New Point(Me.grdDataGrid.GetCellBounds(0, 0).X + 4, Me.grdDataGrid.GetCellBounds(0, 0).Y + 4) End If End If intNewAnz = Me.BindingContext(Me.DseDataSetPatient1, "KHSPET0").Count If intAktAnz = intNewAnz Then blnSatzAnzahlEnde = True End If If intSatzAnzahl > intNewAnz Then blnSatzAnzahlEnde = True End If intSatzAnzahl = intNewAnz Me.Cursor = Windows.Forms.Cursors.Default Me.grdDataGrid.Refresh() End If End If Catch ex As Exception ErrorMessage(...) Finally End Try End Sub Sometimes this works fine. But sometimes it seems that the scroll event is fired again and again. Or in some other cases I only get an hourglass and nothing happens. Any idea what I may have forgotten? Quote
AlexCode Posted September 29, 2003 Posted September 29, 2003 (edited) The point is... Does this work worth the effort? Your problem is the time you wait while the DataSet is populated with a huge database isn't it? I don't know where the data comes from but I assume is coming from SQL server 2000... Is it? IF so, it gives you a functionality called CURSORS that does quite what you're looking for. Read some SQL Books (can find some good ones on kazaa). You can also listen to Nerseus on this thread... http://www.xtremedotnettalk.com/t49767.html Edited September 29, 2003 by AlexCode Quote Software bugs are impossible to detect by anybody except the end user.
Heike Posted September 30, 2003 Author Posted September 30, 2003 No, my problem is not the waiting time. Because I only read 25 records a time, it is fast enough. My problem is that I seem to use the scroll event the wrong way or something like that. I am not working with SQL Server 2000; I work with an iSeries. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.