dropDown.Opened+= new EventHandler(dropDown_Opened);
dropDown.Closed+= new ToolStripDropDownClosedEventHandler(dropDown_Closed);
dropDown.MouseWheel+= new MouseEventHandler(dropDown_MouseWheel);
1.添加模拟按键的Keyboard类的代码
public static class Keyboard
{
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern uint keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
const byte VK_UP = 0x26; // Arrow Up key
const byte VK_DOWN = 0x28; // Arrow Down key
const int KEYEVENTF_EXTENDEDKEY = 0x0001; //Key down flag, the key is going to be pressed
const int KEYEVENTF_KEYUP = 0x0002; //Key up flag, the key is going to be released
public static void KeyDown()
{
keybd_event(VK_DOWN, 0, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(VK_DOWN, 0, KEYEVENTF_KEYUP, 0);
}
public static void KeyUp()
{
keybd_event(VK_UP, 0, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(VK_UP, 0, KEYEVENTF_KEYUP, 0);
}
}
1条答案
按热度按时间4ktjp1zp1#
工作溶液:
1.在表单的Load事件中注册
ToolStripDropDown
的MouseWheel
、Opened
、Closed
事件1.添加模拟按键的Keyboard类的代码
1.添加
Opened
、Closed
、MouseWheel
事件的代码:1.为项目1的所有系统创建全局功能
工具条下拉菜单为
ToolStripMenuItem.DropDown
希望对你有帮助。