You can try to handle the key down event and discard any keys you
want. Look at this code. Create a form and add datetimepicker control.
HTH.
Alcides Schulz.(http://alsql.blogspot.com).
public partial class TestDatePicker : Form
{
public TestDatePicker()
{
InitializeComponent();
dateTimePicker1.KeyDown += new
KeyEventHandler(event_KeyDown);
}
private void event_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
Console.WriteLine("KeyDown=" + e.KeyCode.ToString());
if (e.KeyCode.ToString() == "Down" || e.KeyCode.ToString()
== "Up")
{
e.SuppressKeyPress = true;
return;
}
}
}
Franck - 21 Feb 2008 16:10 GMT
private void dateTimePicker1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode.ToString() == "Down" || e.KeyCode.ToString() == "Up")
{
e.Cancel;
}
}
Artie - 21 Feb 2008 16:50 GMT
> You can try to handle the key down event and discard any keys you
> want. Look at this code. Create a form and add datetimepicker control.
[quoted text clipped - 24 lines]
> }
> }
Thanks for your response Alcides.
I'd got one of the Event Handlers, but not the other.
So now I'm implementing the KeyDown and KeyPress event handlers and
doing "e.Handled = true" in each one.
Thanks again.
Artie
Claes Bergefall - 22 Feb 2008 10:29 GMT
<snip>
> if (e.KeyCode.ToString() == "Down" || e.KeyCode.ToString() ==
> "Up")
if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Up)
/claes