• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

VB.NET HelpProvider.GetHelpString方法代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了VB.NET中System.Windows.Forms.HelpProvider.GetHelpString方法的典型用法代码示例。如果您正苦于以下问题:VB.NET HelpProvider.GetHelpString方法的具体用法?VB.NET HelpProvider.GetHelpString怎么用?VB.NET HelpProvider.GetHelpString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.HelpProvider的用法示例。



在下文中一共展示了HelpProvider.GetHelpString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。

示例1: Form1

' 导入命名空间
Imports System.Drawing
Imports System.Windows.Forms

Public Class Form1
    Inherits System.Windows.Forms.Form

    Public Sub New()
        MyBase.New()

        InitializeComponent()
        AddHandlers()
        InitializeFormHelp()

    End Sub

    
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents withdrawal As System.Windows.Forms.TextBox
    Friend WithEvents deposit As System.Windows.Forms.TextBox
    Friend WithEvents ErrorProvider1 As System.Windows.Forms.ErrorProvider
    Friend WithEvents balance As System.Windows.Forms.Label
    Friend WithEvents HelpProvider1 As System.Windows.Forms.HelpProvider

   <System.Diagnostics.DebuggerStepThrough()> Private Sub     InitializeComponent()
        Me.withdrawal = New System.Windows.Forms.TextBox
        Me.deposit = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.ErrorProvider1 = New System.Windows.Forms.ErrorProvider
        Me.balance = New System.Windows.Forms.Label
        Me.HelpProvider1 = New System.Windows.Forms.HelpProvider
        Me.SuspendLayout()
        
        Me.withdrawal.Location = New System.Drawing.Point(32, 200)
        Me.withdrawal.Name = "withdrawal"
        Me.withdrawal.Size = New System.Drawing.Size(88, 20)
        Me.withdrawal.TabIndex = 0
        Me.withdrawal.Text = ""
       
        Me.deposit.Location = New System.Drawing.Point(168, 200)
        Me.deposit.Name = "deposit"
        Me.deposit.TabIndex = 1
        Me.deposit.Text = ""
       
        Me.Label1.Location = New System.Drawing.Point(56, 88)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(96, 24)
        Me.Label1.TabIndex = 2
        Me.Label1.Text = "Account Balance:"
       
        Me.Label2.Location = New System.Drawing.Point(168, 168)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(96, 24)
        Me.Label2.TabIndex = 4
        Me.Label2.Text = "Deposit:"
        
        Me.Label3.Location = New System.Drawing.Point(32, 168)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(96, 24)
        Me.Label3.TabIndex = 5
        Me.Label3.Text = "Withdrawal:"
        
        Me.ErrorProvider1.ContainerControl = Me
        
        Me.balance.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.balance.Location = New System.Drawing.Point(152, 88)
        Me.balance.Name = "balance"
        Me.balance.TabIndex = 6
        Me.balance.Text = "345.65"
        Me.balance.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Controls.Add(Me.balance)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.deposit)
        Me.Controls.Add(Me.withdrawal)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub
 
   
    
    Private Sub AddHandlers()

        'Add the event-handler delegates to handle the KeyDown events.
        AddHandler deposit.KeyDown, _
            New KeyEventHandler(AddressOf ProcessEntry)
        AddHandler withdrawal.KeyDown, _
            New KeyEventHandler(AddressOf ProcessEntry)

        'Add the event-handler delegates to handled the KeyPress events.
        AddHandler deposit.KeyPress, _
            New KeyPressEventHandler(AddressOf CheckForDigits)
        AddHandler withdrawal.KeyPress, _
            New KeyPressEventHandler(AddressOf CheckForDigits)

    End Sub
    Private Sub InitializeFormHelp()

        ' Set the form's border to the FixedDialog style.
        Me.FormBorderStyle = FormBorderStyle.FixedDialog

        ' Remove the Maximize and Minimize buttons from the form.
        Me.MaximizeBox = False
        Me.MinimizeBox = False

        ' Add the Help button to the form.
        Me.HelpButton = True

        ' Set the Help string for the deposit textBox.
        HelpProvider1.SetHelpString(deposit, _
            "Enter an amount in the format xxx.xx" _
                & "and press Enter to deposit.")

        ' Set the Help string for the withdrawal textBox.
        HelpProvider1.SetHelpString(withdrawal, _
            "Enter an amount in the format xxx.xx" _
            & "and press Enter to withdraw.")

    End Sub

    Private Sub ProcessEntry(ByVal sender As Object, _
        ByVal e As KeyEventArgs)

        ' Cast the sender back to a TextBox.
        Dim textBoxSender As Control = CType(sender, TextBox)

        ' Set the error description to an empty string ().
        ErrorProvider1.SetError(textBoxSender, "")

        ' Declare the variable to hold the new balance.
        Dim newBalance As Double

        ' Wrap the code in a Try/Catch block to catch 
        ' errors that can occur when converting the string 
        ' to a double.

        Try
            If (e.KeyCode = Keys.Enter) Then

                ' Switch on the text box that received
                ' the KeyPress event. Convert the text to type double,
                ' and compute the new balance.
                Select Case textBoxSender.Name
                    Case "withdrawal"
                        newBalance = Double.Parse(balance.Text) _
                            - Double.Parse(withdrawal.Text)
                        withdrawal.Text = ""
                    Case "deposit"
                        newBalance = Double.Parse(balance.Text) _
                            + Double.Parse(deposit.Text)
                        deposit.Text = ""
                End Select

                ' Check the value of new balance and set the
                ' Forecolor property accordingly.
                If (newBalance < 0) Then
                    balance.ForeColor = Color.Red
                Else
                    balance.ForeColor = Color.Black
                End If

                ' Set the text of the balance text box
                ' to the newBalance value.
                balance.Text = newBalance.ToString
            End If

        Catch ex As FormatException

            ' If a FormatException is thrown, set the
            ' error string to the HelpString message for 
            ' the control.
            ErrorProvider1.SetError(textBoxSender, _
                HelpProvider1.GetHelpString(textBoxSender))
        End Try
    End Sub


    Private Sub CheckForDigits(ByVal sender As Object, ByVal e _
        As KeyPressEventArgs)

        ' If the character is not a digit, period, or backspace then
        ' ignore it by setting the KeyPressEventArgs.Handled
        ' property to true.
        If Not (Char.IsDigit(e.KeyChar) _
            Or e.KeyChar = "." Or e.KeyChar = ChrW(Keys.Back)) Then
            e.Handled = True
        End If
    End Sub
   

    Public Shared Sub Main()
        Application.Run(New Form1)
    End Sub

End Class
开发者ID:VB.NET开发者,项目名称:System.Windows.Forms,代码行数:204,代码来源:HelpProvider.GetHelpString



注:本文中的System.Windows.Forms.HelpProvider.GetHelpString方法示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
VB.NET HelpProvider.SetHelpString方法代码示例发布时间:2022-05-26
下一篇:
VB.NET DataGridView.InvalidateRow方法代码示例发布时间:2022-05-26
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap