Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
SQL Server

How to use hot key prefix in VB - C

Author: Maliha Atteeq
Download Source Code :

In this simple article you will learn that how to use hot key prefix in vb and C


While playing with the graphics you must keep the following point in your mind:

You can’t draw graphics on simple load event of the form. To create graphics on the form, you must override the onpaint() function of the form.

The syntax of the onpaint() function is:


protected override void OnPaint (PaintEventArgs e)




Dim e As PaintEventArgs



In this article I will tell you that how can we implement hot key prefix.

Hot key prefix:

A hot-key prefix allows you to use a keyboard combination (usually CTRL+HotKey or ALT+HotKey) to access functionality represented by text displayed on the screen.

In order to display the graphics you have to override the function onpaint (). Create a graphics and an object of font object. You can create the object of font class by using this constructor:


Font TextFont = new Font("Times New Roman", 25, FontStyle.Italic);


Dim TextFont As New Font("Times New Roman", 25, FontStyle.Italic)

The next function is the drawString() because we draw the string using hot key prefix. This function has five overloaded methods,depending ob your requirements you can use any of them. The return type of this function is void.

The syntax of the Drawstring() function is:


g.DrawString("SolidBrush", f, hb, 0, 0);


g.DrawString("SolidBrush", f, hb, 0, 0)

To demonstrate make a new window application and write the following code on form’s onpaint event:


protected override void OnPaint(PaintEventArgs e)


            Graphics g = e.Graphics;

            Font = new Font("Times New Roman", 40);

            string str = "This is some &u&n&d&e&r&l&i&n&e&d text!";

            StringFormat strfmt = new StringFormat();

            strfmt.HotkeyPrefix = HotkeyPrefix.Show;

            g.DrawString(str, Font, new SolidBrush(Color.Plum), 10, 10, strfmt);



Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)

    Dim g As Graphics = e.Graphics

    Font = New Font("Times New Roman", 40)

    Dim str As String = "This is some &u&n&d&e&r&l&i&n&e&d text!"

    Dim strfmt As New StringFormat()

    strfmt.HotkeyPrefix = HotkeyPrefix.Show

    g.DrawString(str, Font, New SolidBrush(Color.Plum), 10, 10, strfmt)

End Sub

Now write the following code on FORM LOAD event:


private void Form1_Load(object sender, EventArgs e)


            this.Text = "DEVASP APPLICATION";




Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)



End Sub

This simple article tells that how to use hot key prefix in vb and C

Add Article Comment:
Name :
Email Address :
Comments :
<< How to clone an image in VB - C

Disclaimer - Privacy
© 2002-2017