Articles in this section
Category / Section

How to set Focus for DateTimeEdit?

1 min read

Cursor index position in DateTimeEdit when it have focus can behave based on the OnFocusBehavior property of DateTimeEdit. It can be changed as CursorOnFirstCharacter, CursorAtEnd, and Default.

The same has been explained in the following code snippet:

XAML:

//Code Explains how to set Focus Behavior in DateTimeEdit
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf" x:Class="DateTimeEdit_FocusBehaviour.MainWindow"
Title="MainWindow" Height="350" Width="525">
 
<Grid>
 
<syncfusion:DateTimeEdit Name="DateTime" Width="150" Height="80" Text="DateTimeEdit" OnFocusBehavior="CursorOnFirstCharacter"  />
 
</Grid>
 
</Window>
 

 

C#:

//Code Explains how to set Focus Behavior in DateTimeEdit
namespace DateTimeEdit_FocusBehaviour
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DateTime.OnFocusBehavior=OnFocusBehavior.CursorOnFirstCharacter;
}
}
}

 

Output:

CursorOnFirstCharacter:

            C:\Users\Ashok.Murugesan\Desktop\KBTask\13.4SprintKBTools\ScreenShot\DateTime-Cussorfirstchar.png

 CursorAtEnd:

             C:\Users\Ashok.Murugesan\Desktop\KBTask\13.4SprintKBTools\ScreenShot\DateTime-Cussorlast.png

  Default:

              C:\Users\Ashok.Murugesan\Desktop\KBTask\13.4SprintKBTools\ScreenShot\DateTime-Default.png

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied