1. Introduction
Linklabel is a kind of label control but it serves the purpose of a hyperlink. With this control you can mark a portion of the label text or even the entire label text with an underline. Clicking on the underlined text raises the event LinkClicked. By providing the handler for this event you can take an action.
NumericUpDown control is a combination of text box and a pair of arrows pointing in opposite directions. Clicking the arrow or holding the mouse pointer on the arrow will increment or decrement the associated value. The current value is displayed on the text box part of the control. When we click the arrow an event ValueChanged is raised for taking the action.
2. NumericUpdown control
The value property of this control is used to retrieve the current numeric value of the control. This value property is changed when the up arrow or down arrow buttons are clicked.
Minimum and Maximum properties are used to set the limits of numeric value. Say for example we want the value to be changed from 0 to 255 (For changing the color value), then Minimum property is set to 0 and Maximum property is set to 255.
Increment property is used to increment or decrement the values in steps. For example if we set the Increment to 5, and if the current value of the control is 0, clicking twice the up arrow button will change the value property to 0 to 5 first and then 5 to 10 next.
The importance of ValueChanged event is already discussed in the introduction.
3. LinkLabel Control
LinkColor property is used to set the color of the Underlined portion of the label text. The underlined portion of the label text is called a link. So linkcolor sets the color for the link when it is not visited yet.
LinkVisitedColor property is used to set the color of the link when it is visited. When the property LinkVisited is set to true, the control picks the color from the LinkVisitedColor property and sets that color to link.
The LinkArea property is used to set a portion of the label text as link. This property determines that based on the letters involved in the label text and specifying the link starting location in terms of character and length of character from that location.
We can take the action for clicking a link portion of the label by providing handler for LinkClicked event.
4. Example – Take a Try
Launch "Visual Studio 2005" and Create Visual C# Windows application. Once the application is created design the form as shown below:


Use the table below to set the properties for the control shown in the above screen shot. Each control number in the above screen shot is referred in the C.Number column.
5. Coding
I hope by looking at the dialog design you can understand how it will work and no more explanation is required.
1) Create an event handler for the ValueChanged event of the numericupdown control. In this handler we get the changed value of the control to adjust the width of the text box. Below is the code for that:
//Updown_001: Increase width of the Text box based on the current value
//of the UpDown Control
private void nuUpDown_ValueChanged(object sender, EventArgs e)
{
txtBx.Width = (int) nuUpDown.Value;
}
Now, if you click the up or down arrow button the text box will be resized along its width.
2) Handle the linkclicked event for the control number 1. In the handler we first show a message box and then set the LinkVisited property to true. This will set the different color for the link. Code is given below:
//LinkLabel_001: Handler for the Link clicked event. Display a message when
//the link clicked.
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
MessageBox.Show("Hello There..");
linkLabel1.LinkVisited = true;
}
3) Handle the LinkClicked event for the control number 2. In the handler resize the height of the form to show more controls also set link visited to true. Code is below:
//LinkLabel_002: Handler for the Link clicked event. Display the remaining
//controls.
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
//001: Set that the link is visited
linkLabel2.LinkVisited = true;
//002: Resize the form to show all the controls
this.Height = 200;
}
Note: The Application is created in VS2005. If you have latest version of IDE say "Yes" to the conversion Wizard.