MenuItem 类的Select 事件和Click 事件有什么区别?

mengshui 2003-09-04 09:06:44
rt
...全文
170 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
chengfh 2003-09-09
  • 打赏
  • 举报
回复
click event
Occurs when the menu item is clicked or selected using a shortcut key or access key defined for the menu item.

select event
Occurs when the user places the cursor over a menu item.
mengshui 2003-09-09
  • 打赏
  • 举报
回复
up
alexy 2003-09-08
  • 打赏
  • 举报
回复
只有设置为可以选择的菜单项(就是我们在菜单中看到前面带一个勾的那种)才有select事件。
zhulb 2003-09-07
  • 打赏
  • 举报
回复
click event
Occurs when the menu item is clicked or selected using a shortcut key or access key defined for the menu item.

select event
Occurs when the user places the cursor over a menu item.

you can see the difference
ATField 2003-09-04
  • 打赏
  • 举报
回复
你点一下就是先选择(Select)再Click
Select指的就是菜单被选择(这时还没有点击呢)
比如鼠标在菜单上面移动(或者按方向键),菜单的颜色改变,这个就是选择(Select)

Select event occurs when the user places the cursor over a menu item
thp 2003-09-04
  • 打赏
  • 举报
回复
Select是状态,Click是动作
Private Sub AxWindowsMediaPlayer1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Public Class Form1 Private Sub 文件ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub MenuItem15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditCopy.Click rtBook.Copy() End Sub Private Sub MenuItem16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditPaste.Click rtBook.Paste() '粘贴操作 End Sub Private Sub rtBook_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rtBook.TextChanged fsave = False '控件中的内容发生变化时,该标志为False End Sub Dim fsave As Boolean Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '为全局变量赋值 '对保存文件对话框赋初值 SaveFileDialog1.FileName = "" SaveFileDialog1.DefaultExt = "txt" SaveFileDialog1.Filter = "Text File(*.txt)|*.txt|All files(*.*)|*.*" SaveFileDialog1.Title = "保存" '对打开文件对话框赋初值 OpenFileDialog1.FileName = "" OpenFileDialog1.DefaultExt = "txt" OpenFileDialog1.Filter = "Text File(*.txt)|*.txt|All files(*.*)|*.*" OpenFileDialog1.Title = "打开" End Sub Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileNew.Click Dim num1 As Integer '如果文本已被保存,则清空rtBook内容,重置变量新建文本 If fsave Then rtBook.Clear() SaveFileDialog1.FileName = "" '文件如果还没有保存,则询问用户如何处理 Else num1 = MsgBox("文件的内容已被改变。想保存文件吗?", vbYesNoCancel + 48, "记事本") Select Case num1 '用户选择保存,而且该文件从未保存过,则执行保存文件的操作 Case 6 If SaveFileDialog1.FileName = "" Then If SaveFileDialog1.ShowDialog Then rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If '如果该文件已存在,则弹出对话框,要求用户回答后再保存 End If '清空RTbook的内容,重置变量新建文本 fsave = True rtBook.Clear() SaveFileDialog1.FileName = "" Case 7 '如果用户选择不保存,则立即清空RTbook的内容,新建文本 rtBook.Clear() SaveFileDialog1.FileName = "" fsave = True Case Else '用户选择取消操作,则什么也不做,取消这次的新建操作 End Select End If End Sub Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileOpen.Click Dim num1 As Integer '如果文件内容还未保存,则弹出对话框,询问用户如何处理 If Not fsave Then num1 = MsgBox("文件的内容已被改变。想要保存文件吗?", vbYesNoCancel + 48, "记事本") Select Case num1 Case 6 '用户选择保存操作,而且该文件从未保存过,则输入文件名后进行保存 If SaveFileDialog1.FileName = "" Then If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If Else '若该文件已存在,则弹出对话框,用户选择保存后,直接保存 rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If '弹出【打开】对话框,执行打开文件的操作 fsave = True If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If Case 7 '用户选择不保存文件,则直接打开文本文件 If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText) fsave = True End If Case Else '用户选择了取消操作 End Select Else '文本已被保存,直接打开文件进行操作 If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If fsave = True End If End Sub Private Sub MenuItem8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileSave.Click If SaveFileDialog1.FileName = "" Then '如果文件从未保存过,则弹出对话框,输入文件名后,直接保存 If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If Else '若该文件以保存过,则弹出对话框后,用户选择保存后,直接保存到原文件中 rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If fsave = True End Sub Private Sub MenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileSaveAs.Click '现将保存对话框的标题改为“另存为” SaveFileDialog1.Title = "另存为" If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) fsave = True End If '文件保存完成后,对话框标题再改为“另存” SaveFileDialog1.Title = "保存" End Sub Private Sub MenuItem11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click Close() End Sub Private Sub MenuItem12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditUndo.Click rtBook.Undo() '用户撤消操作 End Sub Private Sub MenuItem14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditCut.Click rtBook.Cut() '剪切操作 End Sub Private Sub MenuItem19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditSelectAll.Click rtBook.SelectAll() '全选操作 End Sub Private Sub MenuItem17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditDelete.Click rtBook.Cut() End Sub Private Sub MenuItem20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFont.Click If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.Font = FontDialog1.Font '用户选择字体 End If End Sub Private Sub MenuItem21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuBackcolor.Click If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.ForeColor = ColorDialog1.Color '选择文本的颜色 End If End Sub Private Sub MenuItem22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuForeColor.Click If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.BackColor = ColorDialog1.Color '选择文本框的背景颜色 End If End Sub Private Sub MenuItem23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuHelpAbout.Click Dim 关于记事本 As Integer 关于记事本 = MsgBox("我的记事本 版本:1.0 版权所有(李振,吕红飞) 2004 http://www.hbsi.com.cn") End Sub

1,977

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧