469,960 Members | 2,533 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,960 developers. It's quick & easy.

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

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
2 1678
tylerb
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
EgoSum
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.

Similar topics

3 posts views Thread by Phil Schmidt | last post: by
2 posts views Thread by Sam | last post: by
6 posts views Thread by Altramagnus | last post: by
1 post views Thread by Stephen Adam | last post: by
5 posts views Thread by ScareCrow | last post: by
1 post views Thread by spamfilteraccount | last post: by
4 posts views Thread by Rex the Strange | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.