Click here to Skip to main content
15,925,444 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to create a "Send To" menu class using C# ? Pin
lin11613-Aug-05 21:35
lin11613-Aug-05 21:35 
GeneralRe: How to create a "Send To" menu class using C# ? Pin
Christian Graus4-Aug-05 17:13
protectorChristian Graus4-Aug-05 17:13 
AnswerRe: How to create a "Send To" menu class using C# ? Pin
lin11614-Aug-05 20:49
lin11614-Aug-05 20:49 
GeneralRe: How to create a "Send To" menu class using C# ? Pin
mav.northwind4-Aug-05 23:42
mav.northwind4-Aug-05 23:42 
GeneralRe: How to create a "Send To" menu class using C# ? Pin
lin11615-Aug-05 15:39
lin11615-Aug-05 15:39 
GeneralHTTP POST & HTTP GET Pin
Mridang Agarwalla3-Aug-05 19:09
Mridang Agarwalla3-Aug-05 19:09 
GeneralRe: HTTP POST & HTTP GET Pin
Mohamad Al Husseiny3-Aug-05 19:13
Mohamad Al Husseiny3-Aug-05 19:13 
GeneralForm can't handle KeyDown event! Pin
levgiang3-Aug-05 18:11
levgiang3-Aug-05 18:11 
When I create a application with a empty form ,I use followed function to handle KeyDown event :

private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
switch (e.KeyCode)
{
case (Keys.Left) :
MessageBox.Show("You have pressed Arrow-Key Left");
break;
case (Keys.Right) :
MessageBox.Show("You have pressed Arrow-Key Right");
break;
}
}
The application runs well but when I add a new button , this function can't handle the KeyDown event ,this code no longer runs properly.Why ?
I use Visual Studio .Net 2003.
Sorry if my English is not good.

This is all code :
-First is Empty form(Run well) :

namespace WindowsApplication2
{
public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;

public Form1()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code

private void InitializeComponent()
{
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
switch (e.KeyCode)
{
case (Keys.Left) :
MessageBox.Show("You have pressed Arrow-Key Left");
break;
case (Keys.Right) :
MessageBox.Show("You have pressed Arrow-Key Right");
break;
}
}
}
}
- After add a button :

namespace WindowsApplication2
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.ComponentModel.Container components = null;

public Form1()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code

private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(104, 80);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
this.ResumeLayout(false);

}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
switch (e.KeyCode)
{
case (Keys.Left) :
MessageBox.Show("You have pressed Arrow-Key Left");
break;
case (Keys.Right) :
MessageBox.Show("You have pressed Arrow-Key Right");
break;
}
}
}
}

le van giang
GeneralRe: Form can't handle KeyDown event! Pin
Christian Graus3-Aug-05 18:20
protectorChristian Graus3-Aug-05 18:20 
GeneralRe: Form can't handle KeyDown event! Pin
Mohamad Al Husseiny3-Aug-05 18:36
Mohamad Al Husseiny3-Aug-05 18:36 
GeneralRe: Form can't handle KeyDown event! Pin
levgiang3-Aug-05 19:07
levgiang3-Aug-05 19:07 
GeneralRe: Form can't handle KeyDown event! Pin
Christian Graus3-Aug-05 19:27
protectorChristian Graus3-Aug-05 19:27 
GeneralRe: Form can't handle KeyDown event! Pin
Anonymous5-Aug-05 18:53
Anonymous5-Aug-05 18:53 
GeneralRe: Form can't handle KeyDown event! Pin
Christian Graus7-Aug-05 13:30
protectorChristian Graus7-Aug-05 13:30 
GeneralWindows forms... Pin
lovelylooney3-Aug-05 17:33
lovelylooney3-Aug-05 17:33 
GeneralRe: Windows forms... Pin
Christian Graus3-Aug-05 17:56
protectorChristian Graus3-Aug-05 17:56 
GeneralRe: Windows forms... Pin
lovelylooney3-Aug-05 18:24
lovelylooney3-Aug-05 18:24 
GeneralRe: Windows forms... Pin
Mohamad Al Husseiny3-Aug-05 18:52
Mohamad Al Husseiny3-Aug-05 18:52 
GeneralRe: Windows forms... Pin
lovelylooney3-Aug-05 19:24
lovelylooney3-Aug-05 19:24 
GeneralError in .Net after adding PayPal webservice - please help!! Pin
nzmike3-Aug-05 17:11
nzmike3-Aug-05 17:11 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
Christian Graus3-Aug-05 17:24
protectorChristian Graus3-Aug-05 17:24 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
nzmike3-Aug-05 17:45
nzmike3-Aug-05 17:45 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
Christian Graus3-Aug-05 17:54
protectorChristian Graus3-Aug-05 17:54 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
nzmike3-Aug-05 18:09
nzmike3-Aug-05 18:09 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
Christian Graus3-Aug-05 18:19
protectorChristian Graus3-Aug-05 18:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.