i'm trying to move the current row in a gdbg to the last row in the grid with
where iRec is the Rowindex of the last row.
But the grid shows only the first row in the grid as the current row. If i try with iRec-1 then the row bevore the last row is going to be the current row.
How can i programmaticly move to the very last row in a gdbg?
Thansk for any Hints!
where lastRow is the last row number in the grid.
RBRenzo BauenMay 6, 2003 05:23 PM UTC
it works fine with your code but not for the last row!!
If i have 10 rows, then with your code, i can reach row 1 to 9 but not row 10!
Tanks for any Hint!
AdministratorMay 6, 2003 08:29 PM UTC
I am not sure what is failing. Things seem to work as expected in the attached sample. If you cannot spot something, if you post a sample, or submit a Direct Trac incident with a sample, then we can look into it.
RBRenzo BauenMay 12, 2003 05:27 AM UTC
well, i had Code like this in the form_Load event:
Dim foundRow As Integer = ds.Tables("MyTable").DefaultView.Find(searchText)
If foundRow >= 0 Then
foundRow = Me.gridDataBoundGrid1.Binder.ListManagerPositionToRowIndex(foundRow)
MsgBox("No Data found!")
I got an instance of the Form and set a property to fill in the search text. Then i showed the form with myform.showdialog to show a list with the searched Record as current record.
The Code above works fine if executet by a button-click on an existing form. But in the load Event of a form it will not work. This was the problem i had. So, after i put the code into the grid_enter event or in the form_activate event it worked fine!
Because the form is NOT drawn by the end of the form load event, the positioning of the record is overwritten by the subsequent draw-events. Positioning works only correct if the grid is allready drawn. Thats why i had to put my code into the enter or activate event!
Thanks for your assistance!
AdministratorMay 12, 2003 07:46 AM UTC
In formload, CurrentCellMoveTo will not 'take' as the grid is not really displayed at that point. So, there is a property that you can set to make the grid 'remember' the move and apply it later when the grid is displayed. So, in formload, set this property to force the move later.
Me.gridDataBoundGrid1.ForceCurrentCellMoveTo = True