sfCheckbox not binding in DataGrid with DataGridTemplateColumn with C# Code

I want to use this article such that I can set the control size of sfCheckBox.

I have used  DataGridCheckBoxColumn but wasn't able to set the checkbox size.

I tried using C# code as below but it is not binding to viewmodel


 // Define GridTemplateColumn for CheckBox

 var checkboxColumn = new DataGridTemplateColumn

 {

     MappingName = "IsSelected",

     Visible =true,

     HeaderText = "Select",

     CellTemplate = new DataTemplate(() =>

     {

         // Create a sfCheckBox and bind it to the "IsSelected" property

         SfCheckBox checkBox = new SfCheckBox();

         checkBox.SetBinding(SfCheckBox.IsCheckedProperty, "IsSelected" );

         checkBox.ControlSize = 14;

         

         return checkBox;

     })

 };

 checkboxColumn.AllowEditing = true;

 dataGrid.Columns.Add(checkboxColumn);


Please help in C# code to use sfCheckbox and  DataGridTemplateColumn to add column to sfDataGrid


1 Reply

SD Sethupathy Devarajan Syncfusion Team September 30, 2024 11:39 AM UTC

Hi Praveen,

It is clear that you need to bind the SfCheckBox in the DataGridTemplate column of the DataGrid. We have addressed your query in a simple sample and shared it for your reference.

 

Regards,

Sethupathy D.


Attachment: SfDataGridSample_f3e173c2.zip

Loader.
Up arrow icon