Skip to content

Commit 837bb8c

Browse files
How to add the RadioButton column in WinForms DataGrid (SfDataGrid)?
1 parent 74d3b48 commit 837bb8c

19 files changed

+1054
-0
lines changed

DataGridDemo/DataGrid_WF/.vs/DataGrid_WF/v16/Server/sqlite3/db.lock

Whitespace-only changes.
Binary file not shown.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28307.168
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataGrid_WF", "DataGrid_WF\DataGrid_WF.csproj", "{278A7C6F-EB74-462E-A8D4-2A09EEECD99B}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Debug-Xml|Any CPU = Debug-Xml|Any CPU
12+
Release|Any CPU = Release|Any CPU
13+
Release-Xml|Any CPU = Release-Xml|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{278A7C6F-EB74-462E-A8D4-2A09EEECD99B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{278A7C6F-EB74-462E-A8D4-2A09EEECD99B}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{278A7C6F-EB74-462E-A8D4-2A09EEECD99B}.Debug-Xml|Any CPU.ActiveCfg = Debug|Any CPU
19+
{278A7C6F-EB74-462E-A8D4-2A09EEECD99B}.Debug-Xml|Any CPU.Build.0 = Debug|Any CPU
20+
{278A7C6F-EB74-462E-A8D4-2A09EEECD99B}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{278A7C6F-EB74-462E-A8D4-2A09EEECD99B}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{278A7C6F-EB74-462E-A8D4-2A09EEECD99B}.Release-Xml|Any CPU.ActiveCfg = Release|Any CPU
23+
{278A7C6F-EB74-462E-A8D4-2A09EEECD99B}.Release-Xml|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {7F9C2EB5-3141-4853-8B3F-D188E2B5085E}
30+
EndGlobalSection
31+
EndGlobal
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
5+
</startup>
6+
</configuration>
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{278A7C6F-EB74-462E-A8D4-2A09EEECD99B}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>DataGrid_WF</RootNamespace>
10+
<AssemblyName>DataGrid_WF</AssemblyName>
11+
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="Syncfusion.Core.WinForms, Version=17.2460.0.46, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
37+
<SpecificVersion>False</SpecificVersion>
38+
<HintPath>..\..\..\..\..\Assemblies\Assemblies\17.2.0.46\4.6\Syncfusion.Core.WinForms.dll</HintPath>
39+
</Reference>
40+
<Reference Include="Syncfusion.Data.WinForms, Version=17.4460.0.46, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
41+
<SpecificVersion>False</SpecificVersion>
42+
<HintPath>..\..\..\..\..\..\Assemblies\17.4.0.46\4.6\Syncfusion.Data.WinForms.dll</HintPath>
43+
</Reference>
44+
<Reference Include="Syncfusion.DataSource.WinForms, Version=17.2460.0.46, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
45+
<SpecificVersion>False</SpecificVersion>
46+
<HintPath>..\..\..\..\..\Assemblies\Assemblies\17.2.0.46\4.6\Syncfusion.DataSource.WinForms.dll</HintPath>
47+
</Reference>
48+
<Reference Include="Syncfusion.GridCommon.WinForms, Version=17.2460.0.46, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
49+
<SpecificVersion>False</SpecificVersion>
50+
<HintPath>..\..\..\..\..\Assemblies\Assemblies\17.2.0.46\4.6\Syncfusion.GridCommon.WinForms.dll</HintPath>
51+
</Reference>
52+
<Reference Include="Syncfusion.SfDataGrid.WinForms, Version=17.4460.0.46, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
53+
<SpecificVersion>False</SpecificVersion>
54+
<HintPath>..\..\..\..\..\..\Assemblies\17.4.0.46\4.6\Syncfusion.SfDataGrid.WinForms.dll</HintPath>
55+
</Reference>
56+
<Reference Include="Syncfusion.SfInput.WinForms, Version=17.4460.0.46, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
57+
<SpecificVersion>False</SpecificVersion>
58+
<HintPath>..\..\..\..\..\..\Assemblies\17.4.0.46\4.6\Syncfusion.SfInput.WinForms.dll</HintPath>
59+
</Reference>
60+
<Reference Include="Syncfusion.SfListView.WinForms, Version=16.3460.0.21, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
61+
<SpecificVersion>False</SpecificVersion>
62+
<HintPath>..\..\..\..\..\Assemblies\Assemblies\16.3.0.21\4.6\Syncfusion.SfListView.WinForms.dll</HintPath>
63+
</Reference>
64+
<Reference Include="Syncfusion.Shared.Base, Version=17.2460.0.46, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
65+
<SpecificVersion>False</SpecificVersion>
66+
<HintPath>..\..\..\..\..\Assemblies\Assemblies\17.2.0.46\4.6\Syncfusion.Shared.Base.dll</HintPath>
67+
</Reference>
68+
<Reference Include="Syncfusion.Tools.Windows, Version=17.4460.0.46, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
69+
<SpecificVersion>False</SpecificVersion>
70+
<HintPath>..\..\..\..\..\..\..\..\Assemblies\WPF\17.1.0.47\4.6\Syncfusion.Tools.Windows.dll</HintPath>
71+
</Reference>
72+
<Reference Include="System" />
73+
<Reference Include="System.ComponentModel.DataAnnotations" />
74+
<Reference Include="System.Core" />
75+
<Reference Include="System.Design" />
76+
<Reference Include="System.Runtime.Serialization" />
77+
<Reference Include="System.Xml.Linq" />
78+
<Reference Include="System.Data.DataSetExtensions" />
79+
<Reference Include="Microsoft.CSharp" />
80+
<Reference Include="System.Data" />
81+
<Reference Include="System.Deployment" />
82+
<Reference Include="System.Drawing" />
83+
<Reference Include="System.Net.Http" />
84+
<Reference Include="System.Windows.Forms" />
85+
<Reference Include="System.Xml" />
86+
</ItemGroup>
87+
<ItemGroup>
88+
<Compile Include="Form1.cs">
89+
<SubType>Form</SubType>
90+
</Compile>
91+
<Compile Include="Form1.Designer.cs">
92+
<DependentUpon>Form1.cs</DependentUpon>
93+
</Compile>
94+
<Compile Include="GridCellRadioButton.cs">
95+
<SubType>Component</SubType>
96+
</Compile>
97+
<Compile Include="GridCellRadioButton.Designer.cs">
98+
<DependentUpon>GridCellRadioButton.cs</DependentUpon>
99+
</Compile>
100+
<Compile Include="GridCellRadioButtonRenderer.cs" />
101+
<Compile Include="GridRadioButtonColumn.cs" />
102+
<Compile Include="OrderInfoCollection.cs" />
103+
<Compile Include="Program.cs" />
104+
<Compile Include="Properties\AssemblyInfo.cs" />
105+
<EmbeddedResource Include="Form1.resx">
106+
<DependentUpon>Form1.cs</DependentUpon>
107+
</EmbeddedResource>
108+
<EmbeddedResource Include="Properties\Resources.resx">
109+
<Generator>ResXFileCodeGenerator</Generator>
110+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
111+
<SubType>Designer</SubType>
112+
</EmbeddedResource>
113+
<Compile Include="Properties\Resources.Designer.cs">
114+
<AutoGen>True</AutoGen>
115+
<DependentUpon>Resources.resx</DependentUpon>
116+
</Compile>
117+
<None Include="Properties\Settings.settings">
118+
<Generator>SettingsSingleFileGenerator</Generator>
119+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
120+
</None>
121+
<Compile Include="Properties\Settings.Designer.cs">
122+
<AutoGen>True</AutoGen>
123+
<DependentUpon>Settings.settings</DependentUpon>
124+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
125+
</Compile>
126+
</ItemGroup>
127+
<ItemGroup>
128+
<None Include="App.config" />
129+
</ItemGroup>
130+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
131+
</Project>

DataGridDemo/DataGrid_WF/DataGrid_WF/Form1.Designer.cs

Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using Syncfusion.WinForms.DataGrid;
2+
using Syncfusion.WinForms.DataGrid.Enums;
3+
using Syncfusion.WinForms.DataGrid.Events;
4+
using System;
5+
using System.Collections;
6+
using System.Collections.Generic;
7+
using System.Collections.ObjectModel;
8+
using System.ComponentModel;
9+
using System.Data;
10+
using System.Drawing;
11+
using System.Globalization;
12+
using System.Linq;
13+
using System.Text;
14+
using System.Threading.Tasks;
15+
using System.Windows.Forms;
16+
17+
namespace DataGrid_WF
18+
{
19+
public partial class Form1 : Form
20+
{
21+
ObservableCollection<OrderInfo> list = new ObservableCollection<OrderInfo>();
22+
public Form1()
23+
{
24+
InitializeComponent();
25+
26+
list.Add(new OrderInfo(1001, "Maria Anders", "Germany", "ALFKI", "Berlin", new DateTime(2020, 06, 12), true, Options.A));
27+
list.Add(new OrderInfo(1002, "Ana Trujilo", "Mexico", "ANATR", "Mexico D.F.", null, true, Options.B));
28+
list.Add(new OrderInfo(1003, "Antonio Moreno", "Mexico", "ANTON", "Mexico D.F.", new DateTime(2020, 06, 12), true, Options.A));
29+
list.Add(new OrderInfo(1004, "Thomas Hardy", "UK", "AROUT", "London", new DateTime(2020, 06, 12), true, Options.B));
30+
list.Add(new OrderInfo(1005, "Christina Berglund", "Sweden", "BERGS", "Lula", new DateTime(2020, 06, 12), true, Options.C));
31+
list.Add(new OrderInfo(1006, "Hanna Moos", "Germany", "BLAUS", "Mannheim", new DateTime(2020, 06, 12), true, Options.A));
32+
list.Add(new OrderInfo(1007, "Frederique Citeaux", "France", "BLONP", "Strasbourg", new DateTime(2020, 06, 12), true, Options.B));
33+
list.Add(new OrderInfo(1008, "Martin Sommer", "Spain", "BOLID", "Madrid", null, true, Options.A));
34+
list.Add(new OrderInfo(1009, "Laurence Lebihan", "France", "BONAP", "Marseille", null, true, Options.C));
35+
list.Add(new OrderInfo(1010, "Elizabeth Lincoln", "Canada", "BOTTM", "Tsawassen", new DateTime(2020, 06, 12), true, Options.A));
36+
this.sfDataGrid1.AutoGenerateColumns = false;
37+
this.sfDataGrid1.AutoSizeColumnsMode = AutoSizeColumnsMode.Fill;
38+
this.sfDataGrid1.DataSource = list;
39+
40+
this.sfDataGrid1.CellRenderers.Add("RadioButton", new GridRadioButtonCellRender(this.sfDataGrid1, Options.A));
41+
42+
this.sfDataGrid1.Columns.Add(new GridNumericColumn() { MappingName = "OrderID" });
43+
this.sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "CustomerName" });
44+
this.sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "CustomerID" });
45+
this.sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "Country" });
46+
this.sfDataGrid1.Columns.Add(new GridRadioButtonColumn() { MappingName = "RadioOptions", ItemCount = 3, Width = 140 });
47+
48+
}
49+
50+
51+
52+
53+
}
54+
55+
56+
57+
58+
}
59+
60+

0 commit comments

Comments
 (0)