Click here to Skip to main content
15,917,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I used SendKeys.Send("{RIGHT}") to move the courser between day,month and year in Datetimepiker .

the event i used changevalue for Datetimepiker. Now if i change the day and the month just then i come back again to datetimepiker the courser move to the year not to the first part (day).so how can i change the focus on the first part .
Posted
Comments
Ralf Meier 18-Jun-15 4:39am    
Show your code ...
Sinisa Hajnal 18-Jun-15 8:08am    
Remove SendKeys command and let users control where they want to write.
Ralf Meier 18-Jun-15 10:37am    
I think, he sends more Keys.Right as he wanted to do ...
loai_maane 18-Jun-15 15:19pm    
dear i am creating program for user to enter data about employees.
my code very long ,but the important code about this issue is :

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
SendKeys.Send("{RIGHT}");

}
loai_maane 18-Jun-15 15:25pm    
i think the problem in the event it self , because when i change the day then the month just and add the data to the data base by pressing a button , then again come back to the datetimepiker the courser move to the year because i did not change the year before.
now i want way to change the focus on the day when i come back to the dtetimepiker.

1 solution

just put SendKeys.Send("{RIGHT}") in function and call it in valuechange event for the datetimepiker,and in click event for button that used to add the data to the data base write dateTimePicker1.Focus(); and call the function again .:

C#
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
    DoTheStuff();

}


private void button1_Click(object sender, EventArgs e)
{


    dateTimePicker1.Focus();
    DoTheStuff();
}
private void DoTheStuff()
{
    SendKeys.Send("{RIGHT}");
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900