Skip to content

Commit 6f96cbf

Browse files
committed
sample
1 parent 5c22ea1 commit 6f96cbf

41 files changed

Lines changed: 1412 additions & 2 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,47 @@
1-
# How-to-make-a-check-box-column-read-only-in-.NET-MAUI-DataGrid-SfDataGrid
2-
This demo shows how to make a check box column read-only in .NET MAUI DataGrid (SfDataGrid)?
1+
# How to make a check box column read only in .NET MAUI DataGrid SfDataGrid
2+
Currently, [SfDataGrid](https://www.syncfusion.com/maui-controls/maui-datagrid) does not offer built-in support for setting a [DataGridCheckBoxColumn](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridCheckBoxColumn.html) as read-only. However, you can fulfill this requirement by incorporating a CheckBox within a `DataGridTemplateColumn` and configuring the `IsEnabled` property of the CheckBox to be `false`.
3+
4+
##### xaml:
5+
```XML
6+
<syncfusion:SfDataGrid ItemsSource="{Binding Employees}"
7+
AutoGenerateColumnsMode="None"
8+
DefaultColumnWidth="155">
9+
<syncfusion:SfDataGrid.Columns>
10+
<syncfusion:DataGridTemplateColumn MappingName="EmployeeStatus"
11+
HeaderText="Employee Status">
12+
<syncfusion:DataGridTemplateColumn.CellTemplate>
13+
<DataTemplate>
14+
<CheckBox IsEnabled="False"
15+
HorizontalOptions="Center"
16+
IsChecked="{Binding EmployeeStatus}" />
17+
</DataTemplate>
18+
</syncfusion:DataGridTemplateColumn.CellTemplate>
19+
</syncfusion:DataGridTemplateColumn>
20+
<syncfusion:DataGridTextColumn MappingName="EmployeeID"
21+
HeaderText="Employee ID" />
22+
<syncfusion:DataGridTextColumn MappingName="Name"
23+
HeaderText="Name" />
24+
<syncfusion:DataGridTextColumn MappingName="IDNumber"
25+
HeaderText="ID Number" />
26+
</syncfusion:SfDataGrid.Columns>
27+
28+
</syncfusion:SfDataGrid>
29+
```
30+
31+
Executing the code example above yields the following output.
32+
33+
<img src="checkBoxColumn.png" width="360">
34+
35+
[View sample in GitHub](https://github.com/SyncfusionExamples/How-to-make-a-check-box-column-read-only-in-.NET-MAUI-DataGrid-SfDataGrid/tree/master)
36+
37+
Take a moment to explore this [documentation](https://help.syncfusion.com/maui/datagrid/overview), where you can find more information about Syncfusion .NET MAUI DataGrid (SfDataGrid) with code examples. Please refer to this [link](https://www.syncfusion.com/maui-controls/maui-datagrid) to learn about the essential features of Syncfusion .NET MAUI DataGrid (SfDataGrid).
38+
39+
##### Conclusion
40+
41+
I hope you enjoyed learning about how to make a check box column read-only in .NET MAUI DataGrid (SfDataGrid)?
42+
43+
You can refer to our [.NET MAUI DataGrid’s feature tour](https://www.syncfusion.com/maui-controls/maui-datagrid) page to learn about its other groundbreaking feature representations. You can also explore our [.NET MAUI DataGrid Documentation](https://help.syncfusion.com/maui/datagrid/getting-started) to understand how to present and manipulate data.
44+
For current customers, you can check out our .NET MAUI components on the [License and Downloads](https://www.syncfusion.com/sales/teamlicense) page. If you are new to Syncfusion, you can try our 30-day [free trial](https://www.syncfusion.com/downloads/maui) to explore our .NET MAUI DataGrid and other .NET MAUI components.
45+
46+
If you have any queries or require clarifications, please let us know in the comments below. You can also contact us through our [support forums](https://www.syncfusion.com/forums), [Direct-Trac](https://support.syncfusion.com/create) or [feedback portal](https://www.syncfusion.com/feedback/maui?control=sfdatagrid), or the feedback portal. We are always happy to assist you!
47+

SfDataGridSample.sln

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.8.34309.116
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfDataGridSample", "SfDataGridSample\SfDataGridSample.csproj", "{B98BD67C-738A-4295-9C50-C99E9AF5C281}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{B98BD67C-738A-4295-9C50-C99E9AF5C281}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{B98BD67C-738A-4295-9C50-C99E9AF5C281}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{B98BD67C-738A-4295-9C50-C99E9AF5C281}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{B98BD67C-738A-4295-9C50-C99E9AF5C281}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{B98BD67C-738A-4295-9C50-C99E9AF5C281}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{B98BD67C-738A-4295-9C50-C99E9AF5C281}.Release|Any CPU.Deploy.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ExtensibilityGlobals) = postSolution
25+
SolutionGuid = {B0D9A0CE-D9C3-4CC3-9746-DDFB2608D4B2}
26+
EndGlobalSection
27+
EndGlobal

SfDataGridSample/App.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:SfDataGridSample"
5+
x:Class="SfDataGridSample.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>

SfDataGridSample/App.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace SfDataGridSample
2+
{
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
9+
MainPage = new AppShell();
10+
}
11+
}
12+
}

SfDataGridSample/AppShell.xaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="SfDataGridSample.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:SfDataGridSample"
7+
Shell.FlyoutBehavior="Disabled"
8+
Title="SfDataGridSample">
9+
10+
<ShellContent
11+
Title="Home"
12+
ContentTemplate="{DataTemplate local:MainPage}"
13+
Route="MainPage" />
14+
15+
</Shell>

SfDataGridSample/AppShell.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace SfDataGridSample
2+
{
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}

SfDataGridSample/MainPage.xaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:syncfusion="clr-namespace:Syncfusion.Maui.DataGrid;assembly=Syncfusion.Maui.DataGrid"
5+
xmlns:local="clr-namespace:SfDataGridSample"
6+
x:Class="SfDataGridSample.MainPage">
7+
8+
<ContentPage.BindingContext>
9+
<local:EmployeeViewModel/>
10+
</ContentPage.BindingContext>
11+
12+
<syncfusion:SfDataGrid ItemsSource="{Binding Employees}"
13+
AutoGenerateColumnsMode="None"
14+
DefaultColumnWidth="155">
15+
<syncfusion:SfDataGrid.Columns>
16+
<syncfusion:DataGridTemplateColumn MappingName="EmployeeStatus"
17+
HeaderText="Employee Status">
18+
<syncfusion:DataGridTemplateColumn.CellTemplate>
19+
<DataTemplate>
20+
<CheckBox IsEnabled="False"
21+
HorizontalOptions="Center"
22+
IsChecked="{Binding EmployeeStatus}" />
23+
</DataTemplate>
24+
</syncfusion:DataGridTemplateColumn.CellTemplate>
25+
</syncfusion:DataGridTemplateColumn>
26+
<syncfusion:DataGridTextColumn MappingName="EmployeeID"
27+
HeaderText="Employee ID" />
28+
<syncfusion:DataGridTextColumn MappingName="Name"
29+
HeaderText="Name" />
30+
<syncfusion:DataGridTextColumn MappingName="IDNumber"
31+
HeaderText="ID Number" />
32+
</syncfusion:SfDataGrid.Columns>
33+
34+
</syncfusion:SfDataGrid>
35+
36+
</ContentPage>

SfDataGridSample/MainPage.xaml.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Microsoft.Maui;
2+
using Microsoft.Maui.Controls.Compatibility;
3+
using Syncfusion.Maui.Data;
4+
using Syncfusion.Maui.DataGrid;
5+
using Syncfusion.Maui.DataGrid.Helper;
6+
using System.Diagnostics;
7+
8+
namespace SfDataGridSample
9+
{
10+
public partial class MainPage : ContentPage
11+
{
12+
public MainPage()
13+
{
14+
InitializeComponent();
15+
}
16+
17+
}
18+
}

SfDataGridSample/MauiProgram.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.Extensions.Logging;
2+
using Syncfusion.Maui.Core.Hosting;
3+
4+
namespace SfDataGridSample
5+
{
6+
public static class MauiProgram
7+
{
8+
public static MauiApp CreateMauiApp()
9+
{
10+
var builder = MauiApp.CreateBuilder();
11+
builder
12+
.UseMauiApp<App>()
13+
.ConfigureFonts(fonts =>
14+
{
15+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
16+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
17+
});
18+
19+
#if DEBUG
20+
builder.Logging.AddDebug();
21+
#endif
22+
builder.ConfigureSyncfusionCore();
23+
return builder.Build();
24+
}
25+
}
26+
}

SfDataGridSample/Model/Employee.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.ComponentModel;
2+
3+
namespace SfDataGridSample
4+
{
5+
public class Employee
6+
{
7+
public string EmployeeID { get; set; }
8+
public string Name { get; set; }
9+
public long IDNumber { get; set; }
10+
public string Title { get; set; }
11+
public int ContactID { get; set; }
12+
public DateTime BirthDate { get; set; }
13+
public string MaritalStatus { get; set; }
14+
public string Gender { get; set; }
15+
public DateTime HireDate { get; set; }
16+
public int SickLeaveHours { get; set; }
17+
public double Salary { get; set; }
18+
public string LoginID { get; set; }
19+
public int ManagerID { get; set; }
20+
public bool EmployeeStatus { get; set; }
21+
public int Rating { get; set; }
22+
}
23+
24+
}

0 commit comments

Comments
 (0)