如何在Windows窗体中塑造文本框和面板?除了在窗口中显示的属性之外是否有任何设计策略...使用可用属性我无法创建自定义形状,请帮助。
答案 0 :(得分:1)
由于winform TextBoxes不公开Paint事件,您需要在WPF中执行它并使用ElementHost here is a WPF Shaped Textbox example。
以下是塑造Panel的示例:
Private Sub Panel1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
Dim panelPath As New System.Drawing.Drawing2D.GraphicsPath
' Set a new rectangle to the same size as the button's
' ClientRectangle property.
Dim newRectangle As Rectangle = New Rectangle(0, 0, Panel1.Width, Panel1.Height)
' Decrease the size of the rectangle.
newRectangle.Inflate(-10, -10)
' Draw the button's border.
e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle)
'Increase the size of the rectangle to include the border.
newRectangle.Inflate(1, 1)
' Create a circle within the new rectangle.
panelPath.AddEllipse(newRectangle)
e.Graphics.DrawPath(Pens.Black, panelPath)
' Set the button's Region property to the newly created
' circle region.
Panel1.Region = New System.Drawing.Region(panelPath)
End Sub