Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

DataGridView & KeyDown, KeyPress events

[es] :: .NET :: DataGridView & KeyDown, KeyPress events

[ Pregleda: 2247 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

L a d y

Član broj: 101977
Poruke: 53
80.74.160.*



Profil

icon DataGridView & KeyDown, KeyPress events13.02.2007. u 07:58 - pre 209 meseci
Treba da sprecim pojavljivanje znaka sa numericke tastature u celijama dataGridView-a i preusmerim njihov unos u textBox1.
Ovaj kod je obavljao zadatak u text box kontrolama, ali kod dataGridView-a, ne sprecava unos u celije, niti iz njih vrsi prosledjivanje.
Ima li neko ideju kako da se to resi?


private void dataGridViewOrders_KeyDown (object sender, KeyEventArgs e)
{

if ((e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9) ||
e.KeyCode == Keys.Add || e.KeyCode == Keys.Divide || e.KeyCode == Keys.Multiply || e.KeyCode == Keys.Subtract || e.KeyCode == Keys.Decimal)
{
// Determine whether the keystroke is a backspace.
if (e.KeyCode != Keys.Back)
{

// Set the flag to true and evaluate in KeyPress event.
flag = true;
}
}
}


private void dataGridViewOrders_KeyPress(object sender, KeyPressEventArgs e)

{
// Check for the flag being set in the KeyDown event.
if flag == true)
{
textBox1.Text = Convert.ToString(e.KeyChar);
// Stop the character from being entered into the control since it is from the numeric keypad.
e.Handled = true;
flag = false;
}

}
 
Odgovor na temu

[es] :: .NET :: DataGridView & KeyDown, KeyPress events

[ Pregleda: 2247 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.