473,406 Members | 2,707 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,406 software developers and data experts.

RightClick in a DataGrid

How do I determine which cell a user has right clicked in?

I want to use a ContextMenu to offer the user a simple Add, Edit, Delete menu option, but I need to detemine which cell the user has right clicked in so that I can set up the necessary code.
Nov 20 '05 #1
2 1266
'Row Cell Click
Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles DataGrid1.MouseDown
Dim myGrid As DataGrid = CType(sender, DataGrid)
Dim hti As System.Windows.Forms.DataGrid.HitTestInfo
hti = myGrid.HitTest(e.X, e.Y)
Select Case hti.Type
Case System.Windows.Forms.DataGrid.HitTestType.Cell
If (hti.Column = 0) Then
If Not (hti.Row = intGridLength) Then
strSearchDealnumber = DataGrid1.Item(hti.Row, hti.Column)

BrianDH

"Supa Hoopsa" wrote:
How do I determine which cell a user has right clicked in?

I want to use a ContextMenu to offer the user a simple Add, Edit, Delete menu option, but I need to detemine which cell the user has right clicked in so that I can set up the necessary code.

Nov 20 '05 #2
Thanks for this Brian, but can I ask what the "intGridLength" variable is and what you have set it to?

"BrianDH" wrote:
'Row Cell Click
Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles DataGrid1.MouseDown
Dim myGrid As DataGrid = CType(sender, DataGrid)
Dim hti As System.Windows.Forms.DataGrid.HitTestInfo
hti = myGrid.HitTest(e.X, e.Y)
Select Case hti.Type
Case System.Windows.Forms.DataGrid.HitTestType.Cell
If (hti.Column = 0) Then
If Not (hti.Row = intGridLength) Then
strSearchDealnumber = DataGrid1.Item(hti.Row, hti.Column)

BrianDH

"Supa Hoopsa" wrote:
How do I determine which cell a user has right clicked in?

I want to use a ContextMenu to offer the user a simple Add, Edit, Delete menu option, but I need to detemine which cell the user has right clicked in so that I can set up the necessary code.

Nov 20 '05 #3

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

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
8
by: Ken Yu | last post by:
Hi, How can i disable "RightClick Menu" in Internet Explorer, when access the frontpage ? tks a lot ! Ken
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
7
by: Dave | last post by:
Are there any add-on products or samples available that can do the following in an vb.net datagrid I want to compare 2 rows in a datagrid - one row from one database and another row for another...
0
by: Peter van der Veen | last post by:
Hi I have a treeview and a bound contextmenu to delete a node. When the user rightclicks the node the menu pops up and one can chosse delete. So far so good. But .... When i use...
5
by: rishabhshrivastava | last post by:
Hi All, I am using a Web Application and I want to customize Right Click Menu as following:- Do Nothing when user does a Right Click. When user select some text and does a Right Click he/she...
1
by: buss123 | last post by:
Hi to all , pls tell me how to disable the RefreshButton in Browser toolbar , F5 and RightClick in the IE and FireFox browsers by using javaScript Functions Please tell me how to...
1
by: cirfu | last post by:
when i rightclick in python idle i get set breakpoint or something. n options i dont find a way to change to the normal copy/paste options.
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.