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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EgoSum
    New Member
    • Mar 2007
    • 20

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

    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?

    Code:
    public class myDateTextBox : AMS.TextBox.DateTextBox
    {[INDENT]
    protected override bool ProcessDialogKey(Keys keyData)
    {[INDENT]if (keyData >= Keys.NumPad0 && keyData <= Keys.NumPad9)
    {[INDENT]
    return true;[/INDENT]
    }[/INDENT]
    return base.ProcessDialogKey(keyData);
    }[/INDENT]
    }

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

    Code:
    public class x
    { // ...[INDENT]private void textBox_KeyDown(object sender, KeyEventArgs e)
    {[INDENT]
    if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9)
    {[INDENT]
    textBox.Text = Convert.ToString(e.KeyData);[/INDENT]
    }[/INDENT]
    }[/INDENT]
    }
    Thanks for any help.
    Last edited by kenobewan; Mar 15 '07, 01:55 AM. Reason: Add code tags
  • tylerb
    New Member
    • Mar 2007
    • 8

    #2
    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?

    Comment

    • EgoSum
      New Member
      • Mar 2007
      • 20

      #3
      Originally posted by tylerb
      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(o bject sender, KeyEventArgs e) {
      if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9) {
      textBox.Text = Convert.ToStrin g(e.KeyData);
      }
      }
      }

      The code disallow input number from numeric keyboard in dateTextBox, but the passing to textBox not working.

      Comment

      Working...