944,041 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 105291
  • C# RSS
Mar 8th, 2007
0

Capturing "Enter" key event in C# windows application

Expand Post »
I have created an aplication in C# windows application version 1.1 to display some records in a datagrid.
The datasource of the datagrid is datatable and not any database.I want tht when we edit any cell of a particular column
and press "Enter" it should show a Message Box let's say "the cell is edited."
I wrote this but its not working
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue.ToString()=="Enter")
{
// When the user presses both the 'Alt' key and 'F' key,
// KeyPreview is set to False, and a message appears.
// This message is only displayed when KeyPreview is set to True.
this.KeyPreview = false;
MessageBox.Show("KeyPreview is True, and this is from the FORM.");
}
}
Can anybody have any idea?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster
bhavna_816 is offline Offline
116 posts
since Sep 2006
Mar 8th, 2007
0

Re: Capturing "Enter" key event in C# windows application

Hey, do you mean something like this?

C# Syntax (Toggle Plain Text)
  1. private void [your data grid name](object sender, KeyPressEventArgs e)
  2. {
  3. if (e.KeyChar == 13)
  4. {
  5. MessageBox.Show("Enter pressed", "Attention");
  6. }
  7. }

How does that work?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
covertx is offline Offline
21 posts
since May 2006
Mar 8th, 2007
0

Re: Capturing "Enter" key event in C# windows application

Click to Expand / Collapse  Quote originally posted by covertx ...
Hey, do you mean something like this?

C# Syntax (Toggle Plain Text)
  1. private void [your data grid name](object sender, KeyPressEventArgs e)
  2. {
  3. if (e.KeyChar == 13)
  4. {
  5. MessageBox.Show("Enter pressed", "Attention");
  6. }
  7. }

How does that work?
thanks for helping !
I got the solution!
Reputation Points: 10
Solved Threads: 0
Junior Poster
bhavna_816 is offline Offline
116 posts
since Sep 2006
Oct 13th, 2009
1

enter event

I Have 2 text box and I am enter the first numbers and then press enter go to next textbox this event I want. . . . . . . . . . .

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication5
{
public partial class Form1 : Form
{
public Form1()
{

InitializeComponent();
}

private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox1.KeyDown += new eventHandler(textBox1_KeyPress);
}

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Keys.Enter) textBox2.Focus();

}

private void textBox1_Enter(object sender, EventArgs e)
{


}
}
}
Reputation Points: 10
Solved Threads: 0
Newbie Poster
PARAS PATEL is offline Offline
1 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Getting an exception "Attempted to read or write protected memory." Why?
Next Thread in C# Forum Timeline: Please Help me on these topics





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC