本文整理汇总了VB.NET中System.Windows.Forms.GroupBoxRenderer类的典型用法代码示例。如果您正苦于以下问题:VB.NET GroupBoxRenderer类的具体用法?VB.NET GroupBoxRenderer怎么用?VB.NET GroupBoxRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GroupBoxRenderer类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Form1
' 导入命名空间
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Windows.Forms.VisualStyles
Class Form1
Inherits Form
Private WithEvents button1 As Button
Public Sub New()
Dim GroupBox1 As New CustomGroupBox()
button1 = New Button()
GroupBox1.Text = "Radio Button Display"
Me.button1.Location = New System.Drawing.Point(185, 231)
Me.button1.Size = New System.Drawing.Size(105, 23)
Me.button1.Text = "Toggle Visual Styles"
Controls.Add(GroupBox1)
Me.Controls.Add(Me.button1)
' Add some radio buttons to test the CustomGroupBox.
Dim count As Integer = 8
Dim ButtonArray(count) As RadioButton
For i = 0 To count - 1
ButtonArray(i) = New RadioButton()
ButtonArray(i).Text = "Button " +(i + 1).ToString()
GroupBox1.Controls.Add(ButtonArray(i))
Next
If Application.RenderWithVisualStyles Then
Me.Text = "Visual Styles Enabled"
Else
Me.Text = "Visual Styles Disabled"
End If
End Sub
<STAThread()> _
Shared Sub Main()
' If you do not call EnableVisualStyles below, then
' GroupBoxRenderer automatically detects this and draws
' the group box without visual styles.
Application.EnableVisualStyles()
Application.Run(New Form1())
End Sub
' Match application style and toggle visual styles off
' and on for the application.
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) _
Handles button1.Click
GroupBoxRenderer.RenderMatchingApplicationState = True
Application.VisualStyleState = _
Application.VisualStyleState Xor _
VisualStyleState.ClientAndNonClientAreasEnabled
If Application.RenderWithVisualStyles Then
Me.Text = "Visual Styles Enabled"
Else
Me.Text = "Visual Styles Disabled"
End If
End Sub
End Class
Public Class CustomGroupBox
Inherits Control
Private innerRectangle As New Rectangle()
Private state As GroupBoxState = GroupBoxState.Normal
Private panel As New FlowLayoutPanel()
Public Sub New()
Me.Size = New Size(200, 200)
Me.Location = New Point(10, 10)
Me.Controls.Add(panel)
Me.Text = "CustomGroupBox"
Me.Font = SystemFonts.IconTitleFont
innerRectangle.X = ClientRectangle.X + 5
innerRectangle.Y = ClientRectangle.Y + 15
innerRectangle.Width = ClientRectangle.Width - 10
innerRectangle.Height = ClientRectangle.Height - 20
panel.FlowDirection = FlowDirection.TopDown
panel.Location = New Point(innerRectangle.X + 5, innerRectangle.Y + 5)
panel.Size = New Size(innerRectangle.Width - 10, innerRectangle.Height - 10)
End Sub
' Draw the group box in the current state.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
GroupBoxRenderer.DrawGroupBox(e.Graphics, ClientRectangle, Me.Text, Me.Font, state)
' Draw an additional inner border if visual styles are enabled.
If Application.RenderWithVisualStyles Then
GroupBoxRenderer.DrawGroupBox(e.Graphics, innerRectangle, state)
End If
End Sub
' Pass added controls to the internal FlowLayoutPanel.
Protected Overrides Sub OnControlAdded(ByVal e As ControlEventArgs)
MyBase.OnControlAdded(e)
' Ensure that you do not add the panel itself.
If e.Control IsNot Me.panel Then
Me.Controls.Remove(e.Control)
panel.Controls.Add(e.Control)
End If
End Sub
End Class