Open Panel as ToolStrip MenuItem after click on menu C#
来源:互联网 发布:手机录音放大软件 编辑:程序博客网 时间:2024/06/05 02:33
1down vote
Assuming WinForms, you can use a ToolStripControlHost to hold a Panel or a UserControl:
The control to show in the pop-up:
var panel = new Panel() { BackColor = Color.White, MinimumSize = new Size(150, 72), Size = MinimumSize, };panel.Paint += (s, e) => { TextRenderer.DrawText(e.Graphics, "Pop-up Panel", SystemFonts.DefaultFont, panel.ClientRectangle, Color.Black, Color.Empty, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);};
The ToolStrip controls to show the panel:
var hostTool = new ToolStripControlHost(panel) { Padding = Padding.Empty, Margin = Padding.Empty }; var downButton = new ToolStripDropDownButton("Panel Menu") { Alignment = ToolStripItemAlignment.Right, DisplayStyle = ToolStripItemDisplayStyle.Text, DropDownDirection = ToolStripDropDownDirection.BelowLeft, }; ((ToolStripDropDownMenu)downButton.DropDown).ShowCheckMargin = false; ((ToolStripDropDownMenu)downButton.DropDown).ShowImageMargin = false; downButton.DropDown.AutoSize = false; downButton.DropDown.Size = new Size(panel.Width + 12, panel.Height + 4); downButton.DropDown.Items.Add(hostTool); var tool = new ToolStrip(); tool.Items.Add(downButton); this.Controls.Add(tool);
Result:
1down vote
Assuming WinForms, you can use a ToolStripControlHost to hold a Panel or a UserControl:
The control to show in the pop-up:
var panel = new Panel() { BackColor = Color.White, MinimumSize = new Size(150, 72), Size = MinimumSize, };panel.Paint += (s, e) => { TextRenderer.DrawText(e.Graphics, "Pop-up Panel", SystemFonts.DefaultFont, panel.ClientRectangle, Color.Black, Color.Empty, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);};
The ToolStrip controls to show the panel:
var hostTool = new ToolStripControlHost(panel) { Padding = Padding.Empty, Margin = Padding.Empty }; var downButton = new ToolStripDropDownButton("Panel Menu") { Alignment = ToolStripItemAlignment.Right, DisplayStyle = ToolStripItemDisplayStyle.Text, DropDownDirection = ToolStripDropDownDirection.BelowLeft, }; ((ToolStripDropDownMenu)downButton.DropDown).ShowCheckMargin = false; ((ToolStripDropDownMenu)downButton.DropDown).ShowImageMargin = false; downButton.DropDown.AutoSize = false; downButton.DropDown.Size = new Size(panel.Width + 12, panel.Height + 4); downButton.DropDown.Items.Add(hostTool); var tool = new ToolStrip(); tool.Items.Add(downButton); this.Controls.Add(tool);
Result:
0 0
- Open Panel as ToolStrip MenuItem after click on menu C#
- C# Menu中共享MenuItem
- note : append menu to menu on right click menu
- note : CRichEdit right click menu on CView
- Right Click Menu Lag on my pc
- Menu和MenuItem
- wpf click on datagrid to open tab
- Keep Bootstrap dropdown open on click
- Java.MenuBar.Menu.MenuItem.CheckboxMenuItem
- C#中的toolStrip控件
- C# 工具栏ToolStrip
- [学习]MS panel menu
- Show up in the "Open in..." menu on iOS
- 动态改变actionbar的menu菜单MenuItem
- cocos2d x3.3 Menu、MenuItem等相关
- cocos2dx 3.X 中 Menu, MenuItem 注意事项
- Menu菜单,MenuBar菜单栏,MenuItem菜单项
- users can not login after click on activation link. VM and CB
- React-Native学习指南
- 正则表达式、扩展表达式以及相关实战
- ubuntu配置全局环境变量后开新shell变量无效的解决方法
- ASIHTTPRequest -- 断点续传
- hdu1082 Matrix Chain Multiplication
- Open Panel as ToolStrip MenuItem after click on menu C#
- BZOJ4316: 小C的独立集
- iOS AVPlayer音频播放应用
- js中将字符串转换成数字
- 微信创建自定义菜单和删除自定义菜单
- 使用ViewGrop和Fragment对Fragmen进行缓存
- 在Ubuntu下安装nodejs4.x,并实现开机自动启动forever进程守护nodejs应用后台运行
- 全局大喇叭,广播机制初篇。
- 访问注解与自定义注解