Hi friends, in this article I will explain about How to Add
ToolTips to Controls on a Windows Form or Tooltip to button in vb.net/C# or .NET
- How can I display a tooltip over a button using Windows forms or how to set hand symbol to button.
In previous articles I already explained about Windows Forms.
Lets I will explain how to add tooltips to button
First create one new project.
File--- New---Project---select windows
Application --give name to form as aspdotnet-roja.vb
Then one form will be created. Drag and Drop the ToolTip control from ToolBox to the
Form as shown in the figure.
Take one button on the form and give the id and text as ASPDOTNETROJA
Set the text of the property to the tool tip text you would
like to display.I give as "Connect to
ASPDOTNETROJA facebook").
Double click on the button and write the following code in
the Form Load
ToolTip1.SetToolTip(AspdotnetRoja, "Connect to ASPDOTNETROJA facebook")
|
I explained with one small example.
I take one button and I redirect to my facebook page when
anyone click on the button.
Below is the code for my example.
In VB.NET:
Public Class Form1
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ToolTip1.SetToolTip(AspdotnetRoja, "Connect to ASPDOTNETROJA facebook")
AspdotnetRoja.Cursor = System.Windows.Forms.Cursors.Hand
End Sub
Private Sub AspdotnetRoja_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles AspdotnetRoja.Click
Process.Start("www.facebook.com/aspdotnetroja")
End Sub
End Class
|
In C#:
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
Public Class Form1
{
private
void Form1_Load(System.Object sender, System.EventArgs e)
{
ToolTip1.SetToolTip(AspdotnetRoja,
"Connect to ASPDOTNETROJA facebook");
AspdotnetRoja.Cursor = System.Windows.Forms.Cursors.Hand;
}
private
void AspdotnetRoja_Click(System.Object sender, System.EventArgs e)
{
Process.Start("www.facebook.com/aspdotnetroja");
}
Public
Form1()
{
Load += Form1_Load;
}
}
|
Save the program and Run. The output of above program is as shown
in the below figure.
Its very nice...
ReplyDelete