473,382 Members | 1,651 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Datagrid scrolling onCurrentCellChanged

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.Parent.MousePosition.X,dgrid.Parent.Mo usePosition.Y)
'Convert Screen Coordinates to Local Coordinates
Dim pC As Point = dgrid.PointToClient(p)

'Runs Hit Test on Datagrid
Dim ht As DataGrid.HitTestInfo = dgrid.HitTest(pC)

'Check if Mouse is over Cell
If ht.Type = DataGrid.HitTestType.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.CurrentCell = New DataGridCell(r, c)

'Gets Information for passing to paint method
Dim ds As DataGridTableStyle = dgrid.TableStyles(0)
Dim d As DataGridEnableTextBoxColumn
Dim curr As CurrencyManager
Dim g As Graphics = dgrid.CreateGraphics
Dim rect As Rectangle
Dim fBrush As SolidBrush = NewSolidBrush(Color.Gold)
Dim bBrush As SolidBrush = NewSolidBrush(Color.FromArgb(51, 51, 51))
curr =CType(dgrid.Parent.BindingContext(dgrid.DataSourc e),CurrencyManager)
'Loops through all columns
Dim i As Integer
For i = 0 To dgrid.VisibleColumnCount - 1
d = CType(ds.GridColumnStyles(i),DataGridEnableTextBox Column)
If d.Width > 0 Then
rect = dgrid.GetCellBounds(r, i)
d.PaintCol(g, rect, curr, r, bBrush, fBrush,False)
End If
Next
End If

DataGridEnableTextBoxColumn is a class inherited fromDataGridTextBoxColumn

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 willautomatically 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 gettingseriously sick of uncontrolled scrolling when trying to viewdata

--------------------------------
From: John Bayly

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>D8xzNOKwpEO8bmMSWisn/Q==</Id>
Nov 20 '05 #1
1 2316
Hi
Try this
=======================
Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemCreated
Dim foo As Web.UI.WebControls.DataGridItem = e.Item
foo.Attributes.Add("onmouseover", "bgColor='#345622'")
foo.Attributes.Add("onmouseout", "bgColor=''")
End Sub
=======================

Let me know if its was what ur looking 4
/Jens
"John Bayly via .NET 247" <an*******@dotnet247.com> wrote in message
news:e0****************@TK2MSFTNGP10.phx.gbl...
I'm working on an inherited Datagrid class that includes a function called
onMouseMove to paint the row under the cursor to make 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.Parent.MousePosition.X,
dgrid.Parent.MousePosition.Y)
'Convert Screen Coordinates to Local Coordinates
Dim pC As Point = dgrid.PointToClient(p)

'Runs Hit Test on Datagrid
Dim ht As DataGrid.HitTestInfo = dgrid.HitTest(pC)

'Check if Mouse is over Cell
If ht.Type = DataGrid.HitTestType.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.CurrentCell = New DataGridCell(r, c)

'Gets Information for passing to paint method
Dim ds As DataGridTableStyle = dgrid.TableStyles(0)
Dim d As DataGridEnableTextBoxColumn
Dim curr As CurrencyManager
Dim g As Graphics = dgrid.CreateGraphics
Dim rect As Rectangle
Dim fBrush As SolidBrush = New SolidBrush(Color.Gold)
Dim bBrush As SolidBrush = New SolidBrush(Color.FromArgb(51, 51,
51))
curr = CType(dgrid.Parent.BindingContext(dgrid.DataSource ),
CurrencyManager)
'Loops through all columns
Dim i As Integer
For i = 0 To dgrid.VisibleColumnCount - 1
d = CType(ds.GridColumnStyles(i),
DataGridEnableTextBoxColumn)
If d.Width > 0 Then
rect = dgrid.GetCellBounds(r, i)
d.PaintCol(g, rect, curr, r, bBrush, fBrush, False)
End If
Next
End If

DataGridEnableTextBoxColumn is a class inherited from DataGridTextBoxColumn

The problem I am having is that when the user moves the mouse over the last
visible row in the datagrid (example row=7), it calls the function, and when
the currentcell is changed, it will automatically scroll down by 1 row. The
mouse cursor still remains in the original positions (now over row=8). If
the mouse is moved again, it will scroll down another row. What I need to do
is stop the datagrid from scrolling automatically when the last currentcell
is set to the last visible row.

Does anybody have any idea how to stop this, my users are getting seriously
sick of uncontrolled scrolling when trying to view data

--------------------------------
From: John Bayly

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>D8xzNOKwpEO8bmMSWisn/Q==</Id>
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Igor Mendizabal | last post by:
Hello, We're doing our own datagrid based on the System.windows.forms.datagrid control, and are having some problems with horizontal scrolling. In general, we construct our datagrid adding a...
2
by: Nanda | last post by:
hi, i have an editable datagrid. how can i update the database, When the user completes entering data for a row. i.e., data should be updated whenever user completes entering a row. Thanks in...
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
2
by: Paul Sampson | last post by:
Hello, The DataGrid.CurrentCellChanged requires too much overhead to determine when only the row has changed. Can anyone suggest a way to fire an event when the user selects a different row...
0
by: Rob | last post by:
I am attempting to update a number of combo boxes on a form based on the users selection in the data grid I want the user to be able to select multiple items Using a separate button I can loop...
4
by: Serg Matvienko | last post by:
Hi everybody, My dataGrid is "for read" only.How can I hihglight the whole row of DataGrid when I am navigating through rows? Now I can see only a small triangle on the right side of dataGrid...
2
by: Charlie | last post by:
Hi: Using the WinForms DataGrid, I would like to have the entire row highlight rather than just the cell that was last clicked. How do you do this? Thanks, Charlie
1
by: Craig Banks | last post by:
If a row of data in a dataset has a lot of columns the row displaying the data in a datagrid will run way off the screen. What I'd like to do is display a row of data over several datagrid rows so...
3
by: Brian Tkatch | last post by:
I have a form with two DataGrids, which are kept in sync manually via Stored PROCEDURE calls. That is, when a record is selected on the first grid, a stored PROCEDURE is CALLed to Fill() the next...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.