473,790 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid scrolling onCurrentCellCh anged

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>
Nov 20 '05 #1
1 2355
Hi
Try this
=============== ========
Private Sub DataGrid1_ItemC reated(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles
DataGrid1.ItemC reated
Dim foo As Web.UI.WebContr ols.DataGridIte m = e.Item
foo.Attributes. Add("onmouseove r", "bgColor='#3456 22'")
foo.Attributes. Add("onmouseout ", "bgColor='' ")
End Sub
=============== ========

Let me know if its was what ur looking 4
/Jens
"John Bayly via .NET 247" <an*******@dotn et247.com> wrote in message
news:e0******** ********@TK2MSF TNGP10.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.Par ent.MousePositi on.X,
dgrid.Parent.Mo usePosition.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 = New SolidBrush(Colo r.Gold)
Dim bBrush As SolidBrush = New SolidBrush(Colo r.FromArgb(51, 51,
51))
curr = CType(dgrid.Par ent.BindingCont ext(dgrid.DataS ource),
CurrencyManager )
'Loops through all columns
Dim i As Integer
For i = 0 To dgrid.VisibleCo lumnCount - 1
d = CType(ds.GridCo lumnStyles(i),
DataGridEnableT extBoxColumn)
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 from DataGridTextBox Column

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>D8xzNOKwpEO 8bmMSWisn/Q==</Id>
Nov 20 '05 #2

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

Similar topics

3
1883
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 tablestyle and gridcolumnstyles to that tablestyle. If we have invisible columns, we add the gridcolumnstyle with Width = 0 (couldn't find any other way to do it, because there is no Visible property available...).
2
5610
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 advance.
2
9927
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 (multi-select without modifier keys). I got that working fine, but I also wanted to keep rows selected after a sort, which I do by storing the row's id in an arraylist. The idea was to do the sort and then go back and re-select the rows with that...
2
3209
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 in a windows forms datagrid? Perhaps this can be done by examining the underlying DataTable, but I'm yet to find a way.
0
1303
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 through and get a list of the rows selected like this CurrencyManager cm = (CurrencyManager)this.BindingContext; DataView dv = (DataView)cm.List; for(int i = 0; i < dv.Count; ++i) { if(dg.IsSelected(i))
4
1655
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 moving. Thanks a lot in advance, Serg
2
7076
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
5291
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 the user doesn't have to scroll horizontally. Essentially, I want to wrap a datagrid row (not text in individual columns) with as much control as possible. Make sense? While this seems simple enough on the surface, I can't figure out how to do...
3
2719
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 second DataGrid's DataSource. All that works very well. And, when there are no records to display, it is simply left blank. My issue is that when i scroll the first one, sometimes the second grid shows a bunch of null values (a "new" record). ...
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9986
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.