milicica


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

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


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

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);
}
}
}

Thanks in advance for any help.


Re: Windows Forms General Disallow entry from numeric keyboard to custom date text box and pass entry to text box

TilakGopi

Hi,

Could u be more clear in describing the problem

What do u want to do in ur text box Specify that only.U want to accept numbers or don't want to accept numbers.

Thanx,

Ch.T.Gopi Kumar.






Re: Windows Forms General Disallow entry from numeric keyboard to custom date text box and pass entry to text box

boban.s

Did you tried this one:

public class myDateTextBox : AMS.TextBox.DateTextBox
{
protected override bool ProcessDialogKey(ref Message msg, Keys keyData)
{
if (keyData >= Keys.NumPad0 && keyData <= Keys.NumPad9)
{
return true;
}
return base.ProcessDialogKey(ref msg, keyData);
}
}






Re: Windows Forms General Disallow entry from numeric keyboard to custom date text box and pass entry to text box

milicica


More precisely, ... dateTextBox accept numbers from main keyboard and don't accept numbers from numeric keyboard (vice versa textBox).

When focus on dateTextBox:

Input number from numeric keyboard activate event and write the number in textBox.
Content in dateTextBox doesn't change.

Input number from main keyboard transmit into the dateTextBox.
Content in textBox doesn't change.
boban.s wrote:
Did you tried this one:

public class myDateTextBox : AMS.TextBox.DateTextBox
{
protected override bool ProcessDialogKey(ref Message msg, Keys keyData)
{
if (keyData >= Keys.NumPad0 && keyData <= Keys.NumPad9)
{
return true;
}
return base.ProcessDialogKey(ref msg, keyData);
}
}

Hi, boban.s. Can you more clear describe your idea

Thanks.




Re: Windows Forms General Disallow entry from numeric keyboard to custom date text box and pass entry to text box

boban.s

That code just disallow entry from numeric keyboard. How to transfer entry from one control to another is diferent story. Even if you do succeed you will have problems controling it, and it will be weird for the user to. What you can do instead of transfer every key, to transfer the focus to text box control. You can use KeyDown event for this.