1

I have a few textboxes that will require user input, and I want to add something that the user can revert to in case they forgot the proper syntax required for input.

For example, if in textbox1 the input MUST ALWAYS be something like "bSAMPLE" or "bSAMPLE2" I want to show the user (i.e., bSAMPLE) so that they may see the proper syntax required.

I know I can add a button and show a messagebox, but that just seems too much for something this simple, as for a tooltip, I'm not sure if the user might hover long enough to see the example. Any tips?

Gmac
  • 169
  • 2
  • 14
  • Add a status bar to the form and in the Enter event update the status bar with whatever helpful text applies? – Ňɏssa Pøngjǣrdenlarp Jun 04 '15 at 13:24
  • You might care to have a look at the User Experience site [http://ux.stackexchange.com](here). – Brian Hooper Jun 04 '15 at 13:24
  • If you have a restricted number of valid entries then a TextBox is the wrong control to use. Use a ComboBox instead. If it is more dynamic then use ErrorProvider to give good feedback. – Hans Passant Jun 04 '15 at 13:26
  • Either create an object dedicated to displaying your help text and update it at the enter event for each text box as Plutonix suggested or use tool tips and manually adjust the tool tip properties to suit your purposes (see [link](https://msdn.microsoft.com/en-us/library/System.Windows.Forms.ToolTip_properties(v=vs.110).aspx). – Josh Jun 04 '15 at 13:40
  • This sounds like a job for... the HelpProvider component. It's in the Toolbox so you really should know about it already. – jmcilhinney Jun 04 '15 at 14:05

1 Answers1

0

Did a quick test on some code for the tooltip method, and this works for me:

'In your form's general declarations:
Dim tt As New ToolTip

Private Sub TextBox_Enter(sender As Object, e As EventArgs) Handles TextBox1.Enter, TextBox2.Enter 'list out all your text boxes here
    Dim txtbx As TextBox = sender, dispText As String
    Select Case txtbx.Name
        Case TextBox1.Name
            dispText = "How to use text box 1"
        Case TextBox2.Name
            dispText = "How to use text box 2"
        'flesh out the text for each text box
    End Select
    tt.Show(dispText, txtbx)
End Sub

Private Sub TextBox_Leave(sender As Object, e As EventArgs) Handles TextBox1.Leave, TextBox2.Leave 'finish the list as above
    tt.Hide()
End Sub
Josh
  • 1,088
  • 1
  • 7
  • 16