I'm working on an inherited Datagrid class that includes afunction called onMouseMove to paint the row under the cursor tomake reading easier for users.
To paint the row, the function sets the current cell to by:
'Get Screen Coorinate of Mouse Cursor
Dim p As Point = New Point(dgrid.Par ent.MousePositi on.X,dgrid.Pare nt.MousePositio n.Y)
'Convert Screen Coordinates to Local Coordinates
Dim pC As Point = dgrid.PointToCl ient(p)
'Runs Hit Test on Datagrid
Dim ht As DataGrid.HitTes tInfo = dgrid.HitTest(p C)
'Check if Mouse is over Cell
If ht.Type = DataGrid.HitTes tType.Cell Then
'Get current row and column
Dim r As Integer = ht.Row
Dim c As Integer = ht.Column
'Set Current Cell to Cell under mouse cursor
dgrid.CurrentCe ll = New DataGridCell(r, c)
'Gets Information for passing to paint method
Dim ds As DataGridTableSt yle = dgrid.TableStyl es(0)
Dim d As DataGridEnableT extBoxColumn
Dim curr As CurrencyManager
Dim g As Graphics = dgrid.CreateGra phics
Dim rect As Rectangle
Dim fBrush As SolidBrush = NewSolidBrush(C olor.Gold)
Dim bBrush As SolidBrush = NewSolidBrush(C olor.FromArgb(5 1, 51, 51))
curr =CType(dgrid.Pa rent.BindingCon text(dgrid.Data Source),Currenc yManager)
'Loops through all columns
Dim i As Integer
For i = 0 To dgrid.VisibleCo lumnCount - 1
d = CType(ds.GridCo lumnStyles(i),D ataGridEnableTe xtBoxColumn)
If d.Width > 0 Then
rect = dgrid.GetCellBo unds(r, i)
d.PaintCol(g, rect, curr, r, bBrush, fBrush,False)
End If
Next
End If
DataGridEnableT extBoxColumn is a class inherited fromDataGridTex tBoxColumn
The problem I am having is that when the user moves the mouseover the last visible row in the datagrid (example row=7), itcalls the function, and when the currentcell is changed, it willautomatical ly scroll down by 1 row. The mouse cursor stillremains in the original positions (now over row=8). If the mouseis moved again, it will scroll down another row. What I need todo is stop the datagrid from scrolling automatically when thelast currentcell is set to the last visible row.
Does anybody have any idea how to stop this, my users are gettingseriousl y sick of uncontrolled scrolling when trying to viewdata
--------------------------------
From: John Bayly
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>D8xzNOKwpEO 8bmMSWisn/Q==</Id>