Advertisement
NAK

VB.NET helpProvider

NAK
Jun 24th, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 4.55 KB | None | 0 0
  1. Imports System
  2. Imports System.Drawing
  3. Imports System.Windows.Forms
  4.  
  5. Public Class Form1
  6.     Inherits System.Windows.Forms.Form
  7.     Private addressTextBox As System.Windows.Forms.TextBox
  8.     Private label2 As System.Windows.Forms.Label
  9.     Private cityTextBox As System.Windows.Forms.TextBox
  10.     Private label3 As System.Windows.Forms.Label
  11.     Private stateTextBox As System.Windows.Forms.TextBox
  12.     Private zipTextBox As System.Windows.Forms.TextBox
  13.     Private helpProvider1 As System.Windows.Forms.HelpProvider
  14.     Private helpLabel As System.Windows.Forms.Label
  15.  
  16.     <STAThread()> _
  17.     Shared Sub Main()
  18.         Application.Run(New Form1())
  19.     End Sub 'Main
  20.  
  21.     Public Sub New()
  22.         Me.addressTextBox = New System.Windows.Forms.TextBox()
  23.         Me.helpLabel = New System.Windows.Forms.Label()
  24.         Me.label2 = New System.Windows.Forms.Label()
  25.         Me.cityTextBox = New System.Windows.Forms.TextBox()
  26.         Me.label3 = New System.Windows.Forms.Label()
  27.         Me.stateTextBox = New System.Windows.Forms.TextBox()
  28.         Me.zipTextBox = New System.Windows.Forms.TextBox()
  29.  
  30.         ' Help Label
  31.         Me.helpLabel.Location = New System.Drawing.Point(8, 80)
  32.         Me.helpLabel.Size = New System.Drawing.Size(272, 72)
  33.         Me.helpLabel.TabIndex = 1
  34.         Me.helpLabel.Text = "Click the Help button in the title bar, then click a control " & _
  35.             "to see a Help tooltip for the control.  Click on a control and press F1 to invoke " & _
  36.             "the Help system with a sample Help file."
  37.  
  38.         ' Address Label
  39.         Me.label2.Location = New System.Drawing.Point(16, 8)
  40.         Me.label2.Size = New System.Drawing.Size(100, 16)
  41.         Me.label2.Text = "Address:"
  42.  
  43.         ' Comma Label
  44.         Me.label3.Location = New System.Drawing.Point(136, 56)
  45.         Me.label3.Size = New System.Drawing.Size(16, 16)
  46.         Me.label3.Text = ","
  47.  
  48.         ' Creates the HelpProvider.
  49.         Me.helpProvider1 = New System.Windows.Forms.HelpProvider()
  50.  
  51.         ' Tell the HelpProvider what controls to provide Help for, and
  52.         ' what the Help string is.
  53.         Me.helpProvider1.SetHelpString(Me.addressTextBox, "Enter the street address in this text box.")
  54.         Me.helpProvider1.SetShowHelp(Me.addressTextBox, True)
  55.  
  56.         Me.helpProvider1.SetHelpString(Me.cityTextBox, "Enter the city here.")
  57.         Me.helpProvider1.SetShowHelp(Me.cityTextBox, True)
  58.  
  59.         Me.helpProvider1.SetHelpString(Me.stateTextBox, "Enter the state in this text box.")
  60.         Me.helpProvider1.SetShowHelp(Me.stateTextBox, True)
  61.  
  62.         Me.helpProvider1.SetHelpString(Me.zipTextBox, "Enter the zip code here.")
  63.         Me.helpProvider1.SetShowHelp(Me.zipTextBox, True)
  64.  
  65.         ' Sets what the Help file will be for the HelpProvider.
  66.         Me.helpProvider1.HelpNamespace = "mspaint.chm"
  67.  
  68.         ' Set properties for the different address fields.
  69.  
  70.         ' Address TextBox
  71.         Me.addressTextBox.Location = New System.Drawing.Point(16, 24)
  72.         Me.addressTextBox.Size = New System.Drawing.Size(264, 20)
  73.         Me.addressTextBox.TabIndex = 0
  74.         Me.addressTextBox.Text = ""
  75.  
  76.  
  77.         ' City TextBox
  78.         Me.cityTextBox.Location = New System.Drawing.Point(16, 48)
  79.         Me.cityTextBox.Size = New System.Drawing.Size(120, 20)
  80.         Me.cityTextBox.TabIndex = 3
  81.         Me.cityTextBox.Text = ""
  82.  
  83.         ' State TextBox
  84.         Me.stateTextBox.Location = New System.Drawing.Point(152, 48)
  85.         Me.stateTextBox.MaxLength = 2
  86.         Me.stateTextBox.Size = New System.Drawing.Size(32, 20)
  87.         Me.stateTextBox.TabIndex = 5
  88.         Me.stateTextBox.Text = ""
  89.  
  90.         ' Zip TextBox
  91.         Me.zipTextBox.Location = New System.Drawing.Point(192, 48)
  92.         Me.zipTextBox.Size = New System.Drawing.Size(88, 20)
  93.         Me.zipTextBox.TabIndex = 6
  94.         Me.zipTextBox.Text = ""
  95.  
  96.         ' Add the controls to the form.
  97.         Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.zipTextBox, _
  98.                                        Me.stateTextBox, Me.label3, _
  99.                                        Me.cityTextBox, Me.label2, _
  100.                                        Me.helpLabel, Me.addressTextBox})
  101.  
  102.         ' Set the form to look like a dialog, and show the HelpButton.    
  103.         Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
  104.         Me.HelpButton = True
  105.         Me.MaximizeBox = False
  106.         Me.MinimizeBox = False
  107.         Me.ClientSize = New System.Drawing.Size(292, 160)
  108.         Me.Text = "Help Provider Demonstration"
  109.  
  110.     End Sub 'New        
  111. End Class 'Form1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement