See Also

HtmlBox Class  | HtmlBox Members

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista

Language

Visual Basic

C#

C++

C++/CLI

Show All

See Also Languages PowerWEB TextBox for ASP.NET

KeyDown Event

Dart.PowerWEB.TextBox Namespace > HtmlBox Class : KeyDown Event

Occurs when a key is down while the control has focus.

[Visual Basic]
<DescriptionAttribute("Event raised when a key is down while the control has focus.")> <CategoryAttribute("Action")> Public Event KeyDown() As KeyEventHandler
[C#]
[DescriptionAttribute("Event raised when a key is down while the control has focus.")] [CategoryAttribute("Action")] public event KeyEventHandler KeyDown();
[C++]
[DescriptionAttribute("Event raised when a key is down while the control has focus.")] [CategoryAttribute("Action")] public: __event KeyEventHandler* KeyDown();
[C++/CLI]
[DescriptionAttribute("Event raised when a key is down while the control has focus.")] [CategoryAttribute("Action")] public: event KeyEventHandler^ KeyDown();

Event Data

The event handler receives an argument of type KeyEventArgs containing data related to this event. The following KeyEventArgs properties provide information specific to this event.

PropertyDescription
Alt Gets a value indicating whether the ALT key was pressed.
Control Gets a value indicating whether the CTRL key was pressed.
KeyCode Gets the keyboard code for a KeyEventArgs.KeyDown, KeyEventArgs.KeyPress or KeyEventArgs.KeyUp event.
Shift Gets a value indicating whether the SHIFT key was pressed.

Remarks

The KeyDown event fires when a key is down while the control has focus.

Example

The following example demonstrates PowerWEB events not found in other Server controls.

[Visual Basic] 

'In this example, events fire as the user interacts with a PowerWEB Control
'These events are not found in non-PowerWEB Server controls
'When an event is raised, a PowerWEB control updates with a message

Private Sub PowerWEBControl1_ContextMenuChanged(ByVal sender As Object, ByVal e As LocationEventArgs) Handles PowerWEBControl1.ContextMenuChanged
    PowerWEBControl1.Text = "You pressed the right button"
End Sub

Private Sub PowerWEBControl1_DoubleClick(ByVal sender As Object, ByVal e As LocationEventArgs) Handles PowerWEBControl1.DoubleClick
    PowerWEBControl1.Text = "That was a nice double-click"
End Sub

Private Sub PowerWEBControl1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles PowerWEBControl1.GotFocus
    PowerWEBControl1.Text = "I am focused"
End Sub

Private Sub PowerWEBControl1_HelpRequested(ByVal sender As Object, ByVal e As LocationEventArgs) Handles PowerWEBControl1.HelpRequested
    PowerWEBControl1.Text = "You pressed F1 Need some help?"
End Sub

Private Sub PowerWEBControl1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles PowerWEBControl1.KeyDown
    PowerWEBControl1.Text = "The " + Convert.ToChar(e.KeyCode).ToString() + " key has gone down"
End Sub

Private Sub PowerWEBControl1_KeyPress(ByVal sender As Object, ByVal e As KeyEventArgs) Handles PowerWEBControl1.KeyPress
    PowerWEBControl1.Text = "The " + Convert.ToChar(e.KeyCode).ToString() + " key has been pressed"
End Sub

Private Sub PowerWEBControl1_KeyUp(ByVal sender As Object, ByVal e As KeyEventArgs) Handles PowerWEBControl1.KeyUp
    PowerWEBControl1.Text = "The " + Convert.ToChar(e.KeyCode).ToString() + " key has gone up"
End Sub

Private Sub PowerWEBControl1_LocationClick(ByVal sender As Object, ByVal e As LocationEventArgs) Handles PowerWEBControl1.LocationClick
    PowerWEBControl1.Text = "The button was pressed at (" + e.X.ToString() + "," + e.Y.ToString() + ")"
End Sub

Private Sub PowerWEBControl1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles PowerWEBControl1.LostFocus
    PowerWEBControl1.Text = "I'm losing focus"
End Sub

Private Sub PowerWEBControl1_MouseDown(ByVal sender As Object, ByVal e As LocationEventArgs) Handles PowerWEBControl1.MouseDown
    PowerWEBControl1.Text = "Down goes the mouse button"
End Sub

Private Sub PowerWEBControl1_MouseEnter(ByVal sender As Object, ByVal e As LocationEventArgs) Handles PowerWEBControl1.MouseEnter
    PowerWEBControl1.Text = "That tickles"
End Sub

Private Sub PowerWEBControl1_MouseLeave(ByVal sender As Object, ByVal e As LocationEventArgs) Handles PowerWEBControl1.MouseLeave
    PowerWEBControl1.Text = "Come back"
End Sub

Private Sub PowerWEBControl1_MouseUp(ByVal sender As Object, ByVal e As LocationEventArgs) Handles PowerWEBControl1.MouseUp
    PowerWEBControl1.Text = "Up goes the mouse button"
End Sub

[C#] 

//In this example, events fire as the user interacts with a PowerWEB Control
//These events are not found in non-PowerWEB Server controls
//When an event is raised, a PowerWEB control updates with a message

private void PowerWEBControl1_ContextMenuChanged(object sender, LocationEventArgs e)
{
   PowerWEBControl1.Text =
"You pressed the right button!";
}

private void PowerWEBControl1_DoubleClick(object sender, LocationEventArgs e)
{
   PowerWEBControl1.Text =
"That was a nice double-click!";
}

private void PowerWEBControl1_GotFocus(object sender, System.EventArgs e)
{
   PowerWEBControl1.Text =
"I am focused!";
}

private void PowerWEBControl1_HelpRequested(object sender, LocationEventArgs e)
{
   PowerWEBControl1.Text =
"You pressed F1!  Need some help?";
}

private void PowerWEBControl1_KeyDown(object sender, KeyEventArgs e)
{
   PowerWEBControl1.Text =
"The " + Convert.ToChar(e.KeyCode).ToString() + " key has gone down!";
}

private void PowerWEBControl1_KeyPress(object sender, KeyEventArgs e)
{
   PowerWEBControl1.Text =
"The " + Convert.ToChar(e.KeyCode).ToString() + " key has been pressed!";
}

private void PowerWEBControl1_KeyUp(object sender, KeyEventArgs e)
{
   PowerWEBControl1.Text =
"The " + Convert.ToChar(e.KeyCode).ToString() + " key has gone up!";
}

private void PowerWEBControl1_LocationClick(object sender, LocationEventArgs e)
{
   PowerWEBControl1.Text =
"The button was pressed at (" + e.X.ToString() + "," + e.Y.ToString() + ")!";
}

private void PowerWEBControl1_LostFocus(object sender, System.EventArgs e)
{
   PowerWEBControl1.Text =
"I'm losing focus!";
}

private void PowerWEBControl1_MouseDown(object sender, LocationEventArgs e)
{
   PowerWEBControl1.Text =
"Down goes the mouse button!";
}

private void PowerWEBControl1_MouseEnter(object sender, LocationEventArgs e)
{
   PowerWEBControl1.Text =
"That tickles!";
}

private void PowerWEBControl1_MouseLeave(object sender, LocationEventArgs e)
{
   PowerWEBControl1.Text =
"Come back!";
}

private void PowerWEBControl1_MouseUp(object sender, LocationEventArgs e)
{
   PowerWEBControl1.Text =
"Up goes the mouse button!";
}

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista

See Also

HtmlBox Class  | HtmlBox Members


Send comments on this topic.

Documentation version 3.2.0.0.

© 2009 Dart Communications.  All rights reserved.