Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 6th, 2008, 03:48 AM
Registered User
 
Join Date: Jun 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yuenli
Default Getting cursor position from grid view

Hi! I have a grid view where I would like to get the cursor position from it when user fired event key up. I try to use code as below but it failed because the X and Y position from cursor.position is always out of range. Does anyone know how to solve it? Thanks.:)

private DataGridViewCell clickedCell;
Point cursorPos = dg_item.PointToClient(new Point(Cursor.Position.X, Cursor.Position.Y));
                DataGridView.HitTestInfo hit = dg_item.HitTest(cursorPos.X, cursorPos.Y);
                if (hit.Type == DataGridViewHitTestType.Cell)
                {
                    MessageBox.Show("true");
                    clickedCell =
                        dg_item.Rows[hit.RowIndex].Cells[hit.ColumnIndex];
                }






Similar Threads
Thread Thread Starter Forum Replies Last Post
keyboard cursor position rahesh VB.NET 1 May 8th, 2008 01:27 PM
Cursor.Position iremtoksoz C# 3 January 2nd, 2008 11:41 AM
Word-cursor position using mouse is not changing jahid Pro VB 6 2 February 6th, 2007 05:32 AM
How to set cursor position in a textbox? zayasv VB.NET 2 April 29th, 2006 07:09 AM
aspx cursor position nutrino ASP.NET 1.0 and 1.1 Basics 6 December 29th, 2005 10:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.