By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,435 Members | 2,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,435 IT Pros & Developers. It's quick & easy.

Disallow entry from numeric keyboard to custom datetextbox and pass entry to textbox

P: 20
Can someone help me with custom text box?

I want change behavior custom date text box - disallow entry and pass entry from numeric keyboard to a text box. Code below disallow entry, but how I can pass entry?

Expand|Select|Wrap|Line Numbers
  1. public class myDateTextBox : AMS.TextBox.DateTextBox
  2. {
  3. protected override bool ProcessDialogKey(Keys keyData)
  4. {
    if (keyData >= Keys.NumPad0 && keyData <= Keys.NumPad9)
  5. {
  6. return true;}return base.ProcessDialogKey(keyData);
  7. }}

I try something like this, but it dosen't work.

Expand|Select|Wrap|Line Numbers
  1. public class x
  2. { // ...
    private void textBox_KeyDown(object sender, KeyEventArgs e)
  3. {
  4. if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9)
  5. {
  6. textBox.Text = Convert.ToString(e.KeyData);}}}
Thanks for any help.
Mar 14 '07 #1
Share this Question
Share on Google+
2 Replies


P: 8
Is the datebox in focus when the user is typing? If so then you want the datebox's event handler to pass the numbers to the the textbox rather then the textbox's event handler (that code will not be reached if the datebox is in focus)

Is the disallow working and the passing not working or are they both broken?
Mar 15 '07 #2

P: 20
Is the datebox in focus when the user is typing? If so then you want the datebox's event handler to pass the numbers to the the textbox rather then the textbox's event handler (that code will not be reached if the datebox is in focus)

Is the disallow working and the passing not working or are they both broken?
Yes, the datebox in focus when the user is typing. I try use the datebox's event handler to pass the numbers to the the textbox, but it does not respond. There's an error in above code, this source is correct:

public class x
{
myDateTextBox order;
TextBox textBox;
// ...
private void order_KeyDown(object sender, KeyEventArgs e) {
if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9) {
textBox.Text = Convert.ToString(e.KeyData);
}
}
}

The code disallow input number from numeric keyboard in dateTextBox, but the passing to textBox not working.
Mar 15 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.