D
Dom
I have a handler for the KeyDown event on a textbox --
txtRecNo_KeyDown (object sender, KeyEventArgs e). The code for this
handler will capture the "Enter" key and then execute code. This is
the usual behavior of the Enter Key to most users.
Now, there are times when the user wants to doubleclick in a listview
box, and place that Record in txtRecNo, and then proceed like an Enter
Key has been pressed. I do the following:
ListViewItem m = lvwHistory.SelectedItems[0];
txtRecNo.Text = m.SubItems[lvwHistory_RecNo.Index].Text;
KeyEventArgs a = new KeyEventArgs(Keys.Enter);
txtRecNo_KeyDown(txtRecNo, a);
In my "C" days (not even C++, just C), this was bad form. You never
called a handler in code. The way around it was to use a subroutine
in txtRecNo_KeyDown, and then call this when needed. The problem was
that you were handling a message that was never sent by the system.
Yet I see this sort of thing in examples published on the web at sites
that seem to be knowledgable. Is it acceptable in C-Sharp?
Dom
txtRecNo_KeyDown (object sender, KeyEventArgs e). The code for this
handler will capture the "Enter" key and then execute code. This is
the usual behavior of the Enter Key to most users.
Now, there are times when the user wants to doubleclick in a listview
box, and place that Record in txtRecNo, and then proceed like an Enter
Key has been pressed. I do the following:
ListViewItem m = lvwHistory.SelectedItems[0];
txtRecNo.Text = m.SubItems[lvwHistory_RecNo.Index].Text;
KeyEventArgs a = new KeyEventArgs(Keys.Enter);
txtRecNo_KeyDown(txtRecNo, a);
In my "C" days (not even C++, just C), this was bad form. You never
called a handler in code. The way around it was to use a subroutine
in txtRecNo_KeyDown, and then call this when needed. The problem was
that you were handling a message that was never sent by the system.
Yet I see this sort of thing in examples published on the web at sites
that seem to be knowledgable. Is it acceptable in C-Sharp?
Dom