|
-
August 26th, 2009, 04:47 AM
#1
[RESOLVED] key up triggered twice for one keystroke
I have this datagridview called dgSubregels on my form.
Editmode is set on EditOnEnter
If I press the F2 or F5 key in a certain cell (subArtcode = 2) this should be triggered.
In that case a form is loaded with another datagridview filled with data
On the cell doubleclick of that one the data should return.
This does work, and the passed data does show up into the datagridview, but somehow the event is triggered also after filling in those values, because frmArtikel is opening again after I doubleclick on a cell.
What should I change to let the event trigger only once ?
Code:
//mainform
private void dgSubregels_KeyUp(object sender, KeyEventArgs e)
{
int Rij, Cel;
Rij = dgSubregels.CurrentCell.RowIndex;
Cel = dgSubregels.CurrentCell.ColumnIndex;
if (Convert.ToInt16(e.KeyCode) == KeyF2 || Convert.ToInt16(e.KeyCode) == KeyF5)
{
if (Cel == subArtcode)
{
frmArtikel frmArt = new frmArtikel(dgKop.Left + this.Left + 100, dgKop.Top + this.Top + 50,this);
if (frmArt.ShowDialog(this) == DialogResult.OK)
{
dgSubregels.Rows[Rij].Cells[subArtcode].Value = frmArt.SelectedArtikel[0];
dgSubregels.Rows[Rij].Cells[subArtDesc].Value = frmArt.SelectedArtikel[1];
}
frmArt.Dispose();
}
}
}
//frmArtikel
private void dgArtikelen_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
int SelectedRow = dgArtikelen.SelectedRows[0].Index;
for (int i = 0; i < 9; i++)
{
SelectedArtikel[i] = dgArtikelen.Rows[SelectedRow].Cells[i].Value.ToString();
}
this.DialogResult = DialogResult.OK;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|