表格用vb制作一个选定图形然后鼠标右键再按R键
您可以使用VB编写一个程序来实现您的需求。下面是一个示例程序,它创建一个表格,并在选中图形时,当您按下鼠标右键再按下R键时,会在控制台输出"选定图形,鼠标右键,按下R键"。
Imports System.Windows.Forms
Public Class Form1
Inherits Form
Public Sub New()
Me.DoubleBuffered = True
Me.Width = 500
Me.Height = 500
Me.BackColor = Color.White
End Sub
Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
MyBase.OnMouseDown(e)
If e.Button = MouseButtons.Left Then
Dim rect As New Rectangle(100, 100, 200, 200)
If rect.Contains(e.Location) Then
Me.BackColor = Color.LightGray
Else
Me.BackColor = Color.White
End If
End If
End Sub
Protected Overrides Sub OnKeyDown(e As KeyEventArgs)
MyBase.OnKeyDown(e)
If e.KeyCode = Keys.R AndAlso e.Modifiers = Keys.Control Then
If Me.BackColor = Color.LightGray Then
Console.WriteLine("选定图形,鼠标右键,按下R键")
End If
End If
End Sub
Public Shared Sub Main()
Application.Run(New Form1())
End Sub
End Class
请注意,此示例程序仅在控制台窗口中输出文本,而不是在表格中显示选定图形。如果您需要在表格中显示选定图形,请根据您的具体需求自行修改程序
原文地址: http://www.cveoy.top/t/topic/hSCs 著作权归作者所有。请勿转载和采集!