| |

VerySource

 Forgot password?
 Register
Search
View: 675|Reply: 5

How to add a right-click menu in a Windows or a control? Waiting online

[Copy link]

2

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-2-8 00:30:01
| Show all posts |Read mode
How to add a right-click program to a simple drawing program in Windows
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 United States

Post time: 2020-4-5 06:00:01
| Show all posts
ContextMenuStrip control
Edit the Text of the Items you want, and then select the ContextMenuStrip property of the window you want to pop up as that control.
Reply

Use magic Report

0

Threads

13

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 Singapore

Post time: 2020-4-7 10:45:01
| Show all posts
VS can use ContextMenu control, but need to be transferred from the tool, you can also directly use ContextMenuStrip.

contextMenu1.MenuItems.Clear ();
contextMenu1.MenuItems.Add ("Copy", Control1_Click);
contextMenu1.MenuItems.Add ("Delete", Control2_Click);

// Control1_Click and Control2_Click refer to the event for this action
Reply

Use magic Report

0

Threads

13

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 Singapore

Post time: 2020-4-7 15:45:01
| Show all posts
Finally, add a sentence contextMenu1.Show (Control control, Point pos, LeftRightAlignment alignment);
// The three parameters are the controls that can display the right-click menu, the mouse position, and whether the menu is displayed on the left or right of the mouse
//E.g. ContextMenu1.Show (dataGridView1, e.Location, LeftRightAlignment.Right);
Reply

Use magic Report

2

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-4-13 12:00:01
| Show all posts
I still do n’t understand what you said Because I just learned, please forgive me
Where to add these codes
Whether to write another function or write it directly in
What about private void Form1_Load (object sender, System.EventArgs e)
Reply

Use magic Report

2

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-4-13 13:30:02
| Show all posts
I still do n’t understand
Because you just learned, please forgive me
Where to write these codes
Is added directly
Private void Form1_Load (object sender, System.EventArgs e) still write another function
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list