473,803 Members | 4,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.HitTestInfo Class

5 New Member
I'm trying to give a context menu to my user when they right click on a particular row in my datagrid. I created two functions that pass back the indicies for the row and column. The following code is located in the Mouse_Clicked event point for the datagrid itself. When I right click the first time everything works perfetly, but the next time I right click the context menu comes up but nothing else gets updated. If I left click on the datagrid then right click it behaves normally, so I guess my question is why doesn't the mouse_click event fire correctly when the user right clicks? Here is the code:


Expand|Select|Wrap|Line Numbers
  1.     Private Sub dgridContractors_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgridContractors.MouseClick
  2.         If e.Button = Windows.Forms.MouseButtons.Right Then
  3.             'Hightlight the row
  4.             Me.dgridContractors.Rows(dgridContractors.CurrentRow.Index).Selected = False
  5.             Me.dgridContractors.Rows(NewRowIndex(e.X, e.Y)).Selected = True
  6.  
  7.             With Me.ContextMenuStrip1
  8.                 .Items.Clear()
  9.                 .Items.Add("Delete this record")
  10.                 .Items.Add("Sort by Column """ & dgridContractors.Columns(NewColumnIndex(e.X, e.Y)).HeaderText & """")
  11.             End With
  12.             ContextMenuStrip1.Show(Windows.Forms.Cursor.Position)
  13.         End If
  14.     End Sub
  15.  
  16.     Private Function NewRowIndex(ByVal x As Integer, ByVal y As Integer) As Integer
  17.         Dim info As DataGridView.HitTestInfo = dgridContractors.HitTest(x, y)
  18.         Return info.RowIndex
  19.         info = Nothing
  20.     End Function
  21.  
  22.     Private Function NewColumnIndex(ByVal x As Integer, ByVal y As Integer) As Integer
  23.         Dim info As DataGridView.HitTestInfo = dgridContractors.HitTest(x, y)
  24.         Return info.ColumnIndex
  25.         info = Nothing
  26.     End Function
  27.  
Apr 11 '08 #1
0 986

Sign in to post your reply or Sign up for a free account.

Similar topics

2
9604
by: Fernando Rodriguez | last post by:
Hi, I need to traverse the methods defined in a class and its superclasses. This is the code I'm using: # An instance of class B should be able to check all the methods defined in B #and A, while an instance of class C should be able to check all methods #defined in C, B and A. #------------------------------------------------
1
3346
by: Oplec | last post by:
Hi, I'm learning C++ as a hobby using The C++ Programming Language : Special Edition by Bjarne Stroustrup. I'm working on chpater 13 exercises that deal with templates. Exercise 13.9 asks for me to turn a previously made String class that deals with char's into a templated String class that uses the template parameter C instead of char. I thought it would be fairly simple to do this exercise, but I encoutered many errors for my...
9
4997
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class pointer which points to an instance of a derived class, but when I pass that base class pointer into a function, it can't access the derived object's public functions. Although, the base class pointer does call the appropriate virtual function...
1
1289
by: GG | last post by:
Is there a class similar to DataGrid.HitTestInfo for Keyboard moving? Need to get the coordinates of the grid when the user is using the shift key and arrows Thanks *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
2
1990
by: Tom P | last post by:
I'm trying to use DataGrid.HitTestInfo in my OnMouseDown event but firstly I cannot see it in Intellisense, secondly when I try to use it I get strange 'COMPILE' errors when building the app I'll be happy to provide more details if anyone has any answers I've read some forums and someone else had similar problem but there were no solutions provided Can anyone from MS comment on this?
5
3165
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits CommonPageBase - Contains myPage which inherits PageBase Each of these classes overrides OnInit and ties an event handler
3
4225
by: Gene Hubert | last post by:
I'm using DataTable.ImportRow to move data from one datatable to another... Dim dt, dtTarget As DataTable Dim dr As DataRow dt = DirectCast(Me.DataSource, DataTable) dtTarget = dt.Clone 'copy the data structure dtTarget.DefaultView.Sort = String.Empty 'remove the sort
15
2379
by: Brett Romero | last post by:
I've read on the forums of other people having problems with HitTestInfo not appearing. I've read these but they didn't help: http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/19e0d259a4ba1d47/3c6428decee1637e?q=where+is+hittestinfo&rnum=1#3c6428decee1637e ...
1
1183
by: asprabahar | last post by:
Hi I have a Different Issue the Class DataGrid.HitTestInfo is missing . The issue is when i type DataGrid and then when i type (.) and the HitTestInfo is not diaplaying ,but the say way when i copy from some were and past it in the code it works .. What may be the Issue? Regards Prabakar
0
9703
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
9564
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
10548
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
10316
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
10295
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,...
1
7604
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
5500
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...
0
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.