ToolStrip的LineStyles净

编程入门 行业动态 更新时间:2024-10-24 16:29:21
本文介绍了ToolStrip的LineStyles净的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否有.NET组件类似的东西,如果没有,如何重现呢?

Is there something similar in .NET components and if not, how to reproduce it?

谢谢!

推荐答案

没有没有这样的控制,但的 ToolStripControlHost类将允许您创建自己的自定义ToolStrip的控制。

No there is no such control, but the ToolStripControlHost Class will allow you to create your own custom ToolStrip controls.

更新:检查该类我迅速刮起了

Update: Check this class I quickly whipped up

Public Class LineStyleMenuItem Inherits Windows.Forms.ToolStripMenuItem Private style As Drawing2D.DashStyle Public Property LineStyle() As Drawing2D.DashStyle Get Return style End Get Set(ByVal value As Drawing2D.DashStyle) style = value End Set End Property Public Sub New(ByVal style As Drawing2D.DashStyle) Me.style = style End Sub Private Sub LineStyleMenuItem_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Const line_width As Integer = 6 Const padding As Integer = 6 Dim y As Single = CSng((Me.Height / 2) - (line_width / 2)) Dim p As New Drawing.Pen(Color.Black, line_width) p.DashStyle = style e.Graphics.DrawLine(p, padding, y, Me.Width - padding, y) p.Dispose() End Sub End Class

您可以通过将项目添加到工具条下拉控制使用它:

You can use it by adding items to a Toolstrip Dropdown control:

dropdownbutton.DropDownItems.Add(New LineStyleMenuItem(Drawing2D.DashStyle.Dash)) dropdownbutton.DropDownItems.Add(New LineStyleMenuItem(Drawing2D.DashStyle.DashDot)) dropdownbutton.DropDownItems.Add(New LineStyleMenuItem(Drawing2D.DashStyle.DashDotDot)) dropdownbutton.DropDownItems.Add(New LineStyleMenuItem(Drawing2D.DashStyle.Dot)) dropdownbutton.DropDownItems.Add(New LineStyleMenuItem(Drawing2D.DashStyle.Solid))

和访问点击项目样式像这样:

And access the clicked item style like so:

Private Sub dropdownbutton_DropDownItemClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles dropdownbutton.DropDownItemClicked MsgBox(CType(e.ClickedItem, LineStyleMenuItem).LineStyle) End Sub

更多推荐

ToolStrip的LineStyles净

本文发布于:2023-05-25 10:40:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/226428.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ToolStrip   LineStyles

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!