How to Change the Time Format of the Time Editor in .NET MAUI DataForm (SfDataForm)?
The Syncfusion® .NET MAUI DataForm (SfDataForm) is a powerful component that facilitates creating data entry forms, including time input with specific formats. This article explains how to change the time format of the Time Editor using the Format property.
Initiate the GenerateDataFormItem event handler for the OnGenerateDataFormItem event.
C#:
dataForm.GenerateDataFormItem += OnGenerateDataFormItem;
Within the OnGenerateDataFormItem event, modify the Format property of the DataFormTimeItem to define the desired time format.
C#:
private void OnGenerateDataFormItem(object sender, GenerateDataFormItemEventArgs e) { if (e.DataFormItem!= null) { if (e.DataFormItem.FieldName == "EventTime" && e.DataFormItem is DataFormTimeItem timeItem) { timeItem.Format = "HH:mm"; } } }
The default time format is "hh:mm tt", which shows the 12-hour format with AM/PM.
Download the complete sample on GitHub
Output:
Conclusion:
I hope you enjoyed learning how to change the time format of the time editor in the .NET MAUI DataForm (SfDataForm).
You can refer to our .NET MAUI DataForm feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI DataForm documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI DataForm and other .NET MAUI components.
Please let us know in the comment section below if you have any queries or require clarification. Contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!