Articles in this section
Category / Section

How to customize the check box editor color in .NET MAUI DataForm (SfDataForm)?

2 mins read

Syncfusion .NET MAUI DataForm (SfDataForm) allows us to customize the editors. In this article, we will discuss how to change the color of the check box editor by using the Color property of the DataFormCheckBoxItem in the GenerateDataFormItem event when the AutoGenerateItems is true.

 

Initiate the GenerateDataFormItem event handler to the OnGenerateDataFormItem event.

 

C#:

private SfDataForm dataForm;
 
protected override void OnAttachedTo(ContentPage bindable)
{
    base.OnAttachedTo(bindable);
    this.dataForm = bindable.FindByName<SfDataForm>("dataForm");
    if (dataForm != null )
    {
        dataForm.ItemsSourceProvider = new ItemSourceProvider();
        dataForm.RegisterEditor("Gender", DataFormEditorType.RadioGroup);
        dataForm.RegisterEditor("Address", DataFormEditorType.MultilineText);
        dataForm.RegisterEditor("Country", DataFormEditorType.AutoComplete);
        dataForm.RegisterEditor("City", DataFormEditorType.ComboBox);
        dataForm.RegisterEditor("ReadyToRelocate", DataFormEditorType.Switch);
        dataForm.RegisterEditor("BirthDate", DataFormEditorType.Date);
        dataForm.GenerateDataFormItem += OnGenerateDataFormItem;
    }
}

 

Using the OnGenerateDataFormItem event, on checking the data item is the DataFormCheckBoxItem, set the color to the check box with the Color property according to the requirement.

 

C#:

private void OnGenerateDataFormItem(object sender, GenerateDataFormItemEventArgs e)
{
    if (e.DataFormItem!= null)
    {
        if (e.DataFormItem.FieldName == "FirstGraduate" && e.DataFormItem is DataFormCheckBoxItem checkBoxItem)
        {
            checkBoxItem.Color = Colors.DarkCyan;
        }
    }
}

 

Note:

The default value of color is the default(Color).

 

View the sample on GitHub

 

Output:

 

Customize the combo box editor color in .NET MAUI DataForm (SfDataForm)

 

Conclusion:

 

I hope you enjoyed learning how to customize the check box editor color in the .NET MAUI DataForm (SfDataForm).

 

You can refer to our .NET MAUI DataForm’s feature tour page to learn about its other groundbreaking feature representations. You can also explore our .NET MAUI DataForm documentation to understand how to present and manipulate data.

 

For current customers, you can check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our .NET MAUI DataForm and other .NET MAUI components.

 

If you have any queries or require clarifications, please let us know in the comment section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

 

 

 

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