本文整理匯總了VB.NET中System.Windows.Forms.FontDialog.ShowEffects屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET FontDialog.ShowEffects屬性的具體用法?VB.NET FontDialog.ShowEffects怎麽用?VB.NET FontDialog.ShowEffects使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Windows.Forms.FontDialog
的用法示例。
在下文中一共展示了FontDialog.ShowEffects屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: ElseIf
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
' Set FontMustExist to true, which causes message box error
' if the user enters a font that does not exist.
FontDialog1.FontMustExist = True
' Set a minimum and maximum size to be
' shown in the FontDialog.
FontDialog1.MaxSize = 32
FontDialog1.MinSize = 18
' Show the Apply button in the dialog.
FontDialog1.ShowApply = True
' Do not show effects such as Underline
' and Bold.
FontDialog1.ShowEffects = False
' Save the existing font.
Dim oldFont As System.Drawing.Font = Me.Font
' Show the dialog and save the result.
Dim result As DialogResult = FontDialog1.ShowDialog()
' If The OK button in the Font dialog box is clicked,
' set all the controls' fonts to the chosen font by
' calling the FontDialog1_Apply method.
If result = DialogResult.OK Then
FontDialog1_Apply(Me.Button1, New System.EventArgs)
' If the Cancel button is clicked, set the controls'
' fonts back to the original font.
ElseIf (result = DialogResult.Cancel) Then
Dim containedControl As Control
For Each containedControl In Me.Controls
containedControl.Font = oldFont
Next
End If
End Sub
' Handle the Apply event by setting all controls' fonts to
' the chosen font.
Private Sub FontDialog1_Apply(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles FontDialog1.Apply
Me.Font = FontDialog1.Font
Dim containedControl As Control
For Each containedControl In Me.Controls
containedControl.Font = FontDialog1.Font
Next
End Sub
示例2: FontDialogApplyAction
' 導入命名空間
Imports System.Drawing
Imports System.Windows.Forms
public class FontDialogApplyAction
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Private Sub btnSetFont_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSetFont.Click
Dim old_font As Font = Me.Font
Dim old_color As Color = Me.ForeColor
dlgFont.ShowColor = True ' Let the user select font color.
dlgFont.ShowEffects = True ' Let the user select Strikeout and Underline.
dlgFont.ShowApply = True ' Display the Apply button.
dlgFont.Font = Me.Font ' Set the initial font.
If dlgFont.ShowDialog() = DialogResult.OK Then
SetFormFont(dlgFont.Font, dlgFont.Color)
Else
SetFormFont(old_font, old_color)
End If
End Sub
Private Sub dlgFont_Apply(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles dlgFont.Apply
Dim dlg As FontDialog = DirectCast(sender, FontDialog)
SetFormFont(dlg.Font, dlg.Color)
End Sub
Private Sub SetFormFont(ByVal new_font As Font, ByVal new_color As Color)
Me.Font = new_font
Me.ForeColor = new_color
End Sub
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Public Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.btnSetFont = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.dlgFont = New System.Windows.Forms.FontDialog
Me.SuspendLayout()
'
'btnSetFont
'
Me.btnSetFont.Location = New System.Drawing.Point(8, 8)
Me.btnSetFont.Name = "btnSetFont"
Me.btnSetFont.Size = New System.Drawing.Size(96, 32)
Me.btnSetFont.TabIndex = 0
Me.btnSetFont.Text = "Set Font"
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(8, 48)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(35, 13)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Label1"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(8, 80)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(160, 20)
Me.TextBox1.TabIndex = 2
Me.TextBox1.Text = "Here's a TextBox"
'
'Form1
'
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None
Me.ClientSize = New System.Drawing.Size(325, 273)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.btnSetFont)
Me.Name = "Form1"
Me.Text = "UseFontDialogWithShowEffects"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents btnSetFont As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents dlgFont As System.Windows.Forms.FontDialog
End Class