473,668 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mouse position in datagrid during MouseHover?

Hi,
How can you determine which cell the mouse is positioned over during the
mousehover event?
Thanks so much!
Mel
Nov 17 '05 #1
2 8805
You can grab the mouse positon (Control.MouseP osition) in the MouseHover
event handler, translate the coordinates into something appropriate to the
DataGrid (dataGrid1.Poin tToClient()), determine the portion of the DataGrid
over which the mouse is hovering (dataGrid1.HitT est()), and then examine the
HitTestInfo that is returned to determine if the mouse is over a cell and,
if so, which cell.

private void dataGrid1_Mouse Hover(object sender, System.EventArg s e)
{
DataGrid grid = (DataGrid)sende r;
Point clientPos = grid.PointToCli ent(Control.Mou sePosition);
DataGrid.HitTes tInfo hitInfo = grid.HitTest(cl ientPos);
if (hitInfo.Type == DataGrid.HitTes tType.Cell)
{
// this.dataGrid1[hitInfo.Row, hitInfo.Column]
}
}

--
Tim Wilson
..NET Compact Framework MVP

"melanieab" <me*******@disc ussions.microso ft.com> wrote in message
news:FF******** *************** ***********@mic rosoft.com...
Hi,
How can you determine which cell the mouse is positioned over during the
mousehover event?
Thanks so much!
Mel

Nov 17 '05 #2
Thanks so much!
Mel

"Tim Wilson" wrote:
You can grab the mouse positon (Control.MouseP osition) in the MouseHover
event handler, translate the coordinates into something appropriate to the
DataGrid (dataGrid1.Poin tToClient()), determine the portion of the DataGrid
over which the mouse is hovering (dataGrid1.HitT est()), and then examine the
HitTestInfo that is returned to determine if the mouse is over a cell and,
if so, which cell.

private void dataGrid1_Mouse Hover(object sender, System.EventArg s e)
{
DataGrid grid = (DataGrid)sende r;
Point clientPos = grid.PointToCli ent(Control.Mou sePosition);
DataGrid.HitTes tInfo hitInfo = grid.HitTest(cl ientPos);
if (hitInfo.Type == DataGrid.HitTes tType.Cell)
{
// this.dataGrid1[hitInfo.Row, hitInfo.Column]
}
}

--
Tim Wilson
..NET Compact Framework MVP

"melanieab" <me*******@disc ussions.microso ft.com> wrote in message
news:FF******** *************** ***********@mic rosoft.com...
Hi,
How can you determine which cell the mouse is positioned over during the
mousehover event?
Thanks so much!
Mel


Nov 17 '05 #3

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

Similar topics

0
2675
by: Stephen Williams | last post by:
I am migrating a VB 6 PictureBox control to VB.NET. In VB 6, this control modified its border style during the mouse down and up events to provide user feedback that it was selected. Once selected its position was adjusted in accordance with the mouse move events. After migrating it to VB.NET I tried setting the PictureBox class's BorderStyle to Fixed3D or FixedSingle during the Mouse Down event. However, doing so seems to prevent...
5
7947
by: gsb | last post by:
I track the mouse location like this code: function mousePos(e) { var p = new Object(); if(e) { p.x = e.pageX; p.y = e.pageY; } else { p.x = event.x; p.y = event.y; } ... (show) } document.onmousemove=mousePos; Seems to do fine on many browsers.
3
2066
by: jcrouse | last post by:
I have created a form designer type application (with a lot of you peoples helpJ). It has label controls that are draggable at runtime. The user is also allowed to change some properties such as forecolor, backcolor and font. The labels also are rotatable and the text can also be flipped 180 degrees (the flipped text part is still being worked on). I have one context menu for all 30 labels that allows for the property changes to the labels....
2
15445
by: bretth | last post by:
In a VB.Net Windows Forms application, I have a user control that handles mouse events. Another section of code programmatically adds a label to the control. I would like label to ignore all events allowing the user control to react to the mouse click. Setting the Enabled property on the label to False comes close, but I don't want the font color to change. Does anyone have an idea how .NET implements the code behind the Enabled...
2
2838
by: Saber | last post by:
glb is a global string, I want when moving mouse to a picturebox, change border style of picturebox. the code shown below do that but MouseLeave event fires less than a second after MouseHover, even without leaving the mouse pointer or moving that. I also tried MouseEnter event instead of MouseHover, but they act same here. Private Sub p1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles p1.MouseLeave,...
1
1711
by: DaveS | last post by:
I am trying to capture the mouse click position in a datagrid but I get the following compilation error: Compiler Error Message: BC30002: Type 'System.Windows.Forms.MouseEventArgs' is not defined. Source Error: Line 84: Private myCheckBoxCol As Integer = 0 'my checkbox column Line 85:
1
4492
by: Emanuel | last post by:
I am trying to make a little diagramming app in C# with the 1.1 Framework (currently our standard here at work, will be upgrading to 2005 sometime in the next couple of months). I want to allow them to click on a custom control of mine, drag a line to another custom control, and when they let go draw a connection. With Drag and Drop I am able to get the start and end controls, and draw the final connection line, but I cannot for the life...
1
1341
by: wanwan | last post by:
I'm trying to get the cursor changed to a hand whenever it stops in the form, and have it changed back to default whenever the mouse moves. So the common sense is to use the mousehover and mousemove event. The problem with using mousehover event is the event is triggered only once after the mouse enters the form. I need mousehover to be triggered whenever the mouse stops. Is there a solution to the problem?
5
8063
by: kimiraikkonen | last post by:
Hi, I couldn't find a necessary class which shows when mouse hovers on a link in Webbrowser control. Think of there's a status bar(text), when mouse comes on a link, the URL must be shown in this status bar. How can i do this? Thanks.
0
8378
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
8890
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
8653
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
7398
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5677
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
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2786
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
2
2018
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.