473,320 Members | 1,802 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,320 software developers and data experts.

Help in right click menu in c#

HI there,
I need to make the functionality of right clicking on a datagrid cell and try to invoke some menu driven code. It could be a file opening, file saving or my own event driven code. Is this possible, if so can someone help me with some sample code.
Thanks
john
___
Newsgroups brought to you courtesy of www.dotnetjohn.com
Nov 16 '05 #1
2 5405

http://www.knowdotnet.com/articles/d...useselect.html

Selecting a Data Grid Row with Right Mouse Click
by Les Smith
Clicking on a Datagrid row, with the Right Mouse Button,does not
automatically select the clicked row. How can I select the row in a
Datagrid that the user clicks with the Right Mouse Button?


John Rajendran wrote:
HI there,
I need to make the functionality of right clicking on a datagrid cell and
try to invoke some menu driven code. It could be a file opening, file
saving or my own event driven code. Is this possible, if so can someone
help me with some sample code. Thanks john
___
Newsgroups brought to you courtesy of www.dotnetjohn.com


--

http://texeme.com
Textcasting Technology

Nov 16 '05 #2
Hi John,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to add context menu on right
click. If there is any misunderstanding, please feel free to let me know.

I think we can handle the right click event of each cell's control. Here is
an example:

private void Form1_Load(object sender, System.EventArgs e)
{
this.dataGrid1.ControlAdded +=new
ControlEventHandler(dataGrid1_ControlAdded);
}

private void dataGrid1_ControlAdded(object sender, ControlEventArgs e)
{
if(e.Control is TextBox)
e.Control.MouseUp +=new MouseEventHandler(Control_MouseUp);
}

private void Control_MouseUp(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Right)
MessageBox.Show("Right Clicked!");
}

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #3

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

Similar topics

1
by: dave | last post by:
I first started using HCW.exe to compile .rtf filew created with MS Word a couple of weeks ago. I used the file | new menu then selected New project in the dialog box and everything worked as...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
3
by: Sender | last post by:
The contextmenu I have created has many levels. Like on the main level there are 15 menuitems. Then for each 15 menuitems there are at least 2 menuitems and then for each of these menu items there...
5
by: A-PK | last post by:
Hi, I am using treeview as my menu. my menu is like the following + Users & Groups - Users -Groups + Departmenuts - Engineering
11
by: Terry Olsen | last post by:
How can I catch a right-click on a DropDownMenuItem?
2
by: Mad Scientist Jr | last post by:
I am editing an existing application that has a System.Windows.Forms.TreeView with a right-click menu with several options. I want to get rid of the TreeView alltogether and rip out the code for...
5
by: james | last post by:
Hello, I am having a little trouble creating an event handler for a context menu toolstripmenuitem. I've seen various tutorials and so on, but I keep getting a bit stuck! So far I have a second...
1
by: =?Utf-8?B?SkQ=?= | last post by:
ok, I got a windows xp home edition computer from my friend, it is a custom made one. The windows xp is an OEM product, so microsoft is willing to charge me $59 to tell me how to fix it since its...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.