How to use Tooltip, Error Provider and Notify Icon in Microsoft Visual Basic.Net


In this article I am going to show you how you can use Tool tip, Error Provider and Notify Icon in Microsoft Visual Basic.Net. These controls do not appear on the form but will appear in the component tray under the form.

First of all I am going to give you a brief introduction about Tooltip, Error Provider and Notify Icon in Microsoft Visual Basic.Net.
Tool Tip: - are windows which display some explanatory text when a user hovers mouse over a control.

Notify Icon: - It lets you display an icon in the task bar. To use notify icon you need to set the icon property of the notify icon to set an icon.

Error provider: - it allows you to set an error message for any control if the input is not valid.

First open a new Project in VB.Net and place 1 Text Box, 2 Buttons, Tool tip, Error Provider and Notify Icon on the form.I have changed the name of the buttons to btnerror and btnNotify and also you need to set an icon for the notify icon.
Now open the code windows and type the following code.


Private Sub TextBox1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.MouseHover
ToolTip1.SetToolTip(TextBox1, "Pls enter name here")
End Sub

Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
MsgBox("You have douuble clicked the button")
End Sub

Private Sub btnNotify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNotify.Click
NotifyIcon1.Visible = True
End Sub

Private Sub btnerror_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnerror.Click
Dim name As String
name = TextBox1.Text

If name <> "Sarfaraz" Then
ErrorProvider1.SetError(TextBox1, "Please check your name")
Else
ErrorProvider1.SetError(TextBox1, "")
Exit Sub

End If

End Sub

Regards
Keep Coding


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: