Skip to content

Commit d12063c

Browse files
Merge pull request #1 from MohanramAnbukkarasu/master
Samples has been committed
2 parents 7081554 + 7e7a51e commit d12063c

30 files changed

+2007
-1
lines changed

CS/CustomSummaries_2013.csproj

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" 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>{98621C03-5917-4FBB-9393-C943C55AFD35}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>CustomSummaries</RootNamespace>
11+
<AssemblyName>CustomSummaries</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile />
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+
<Prefer32Bit>false</Prefer32Bit>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<PlatformTarget>AnyCPU</PlatformTarget>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\Release\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
<Prefer32Bit>false</Prefer32Bit>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="Syncfusion.Core.WinForms" />
39+
<Reference Include="Syncfusion.Data.WinForms" />
40+
<Reference Include="Syncfusion.SfDataGrid.WinForms" />
41+
<Reference Include="Syncfusion.GridCommon.WinForms" />
42+
<Reference Include="System" />
43+
<Reference Include="System.ComponentModel.DataAnnotations" />
44+
<Reference Include="System.Core" />
45+
<Reference Include="System.Xml.Linq" />
46+
<Reference Include="System.Data.DataSetExtensions" />
47+
<Reference Include="Microsoft.CSharp" />
48+
<Reference Include="System.Data" />
49+
<Reference Include="System.Deployment" />
50+
<Reference Include="System.Drawing" />
51+
<Reference Include="System.Windows.Forms" />
52+
<Reference Include="System.Xml" />
53+
</ItemGroup>
54+
<ItemGroup>
55+
<Compile Include="CustomSummaryHelper.cs" />
56+
<Compile Include="Form2.cs">
57+
<SubType>Form</SubType>
58+
</Compile>
59+
<Compile Include="Form2.Designer.cs">
60+
<DependentUpon>Form2.cs</DependentUpon>
61+
</Compile>
62+
<Compile Include="Program.cs" />
63+
<Compile Include="Properties\AssemblyInfo.cs" />
64+
<Compile Include="SalesInfo.cs" />
65+
<Compile Include="SalesInfoCollection.cs" />
66+
<EmbeddedResource Include="Form2.resx">
67+
<DependentUpon>Form2.cs</DependentUpon>
68+
</EmbeddedResource>
69+
<EmbeddedResource Include="Properties\Resources.resx">
70+
<Generator>ResXFileCodeGenerator</Generator>
71+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
72+
<SubType>Designer</SubType>
73+
</EmbeddedResource>
74+
<Compile Include="Properties\Resources.Designer.cs">
75+
<AutoGen>True</AutoGen>
76+
<DependentUpon>Resources.resx</DependentUpon>
77+
</Compile>
78+
<None Include="Properties\Settings.settings">
79+
<Generator>SettingsSingleFileGenerator</Generator>
80+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
81+
</None>
82+
<Compile Include="Properties\Settings.Designer.cs">
83+
<AutoGen>True</AutoGen>
84+
<DependentUpon>Settings.settings</DependentUpon>
85+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
86+
</Compile>
87+
</ItemGroup>
88+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
89+
<ItemGroup>
90+
<Reference Include="Syncfusion.Licensing" />
91+
</ItemGroup>
92+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
93+
Other similar extension points exist, see Microsoft.Common.targets.
94+
<Target Name="BeforeBuild">
95+
</Target>
96+
<Target Name="AfterBuild">
97+
</Target>
98+
-->
99+
</Project>

CS/CustomSummaries_2013.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.31101.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomSummaries_2013", "CustomSummaries_2013.csproj", "{98621C03-5917-4FBB-9393-C943C55AFD35}"
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+
{98621C03-5917-4FBB-9393-C943C55AFD35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{98621C03-5917-4FBB-9393-C943C55AFD35}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{98621C03-5917-4FBB-9393-C943C55AFD35}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{98621C03-5917-4FBB-9393-C943C55AFD35}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

CS/CustomSummaryHelper.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#region Copyright Syncfusion Inc. 2001-2018.
2+
// Copyright Syncfusion Inc. 2001-2018. All rights reserved.
3+
// Use of this code is subject to the terms of our license.
4+
// A copy of the current license can be obtained at any time by e-mailing
5+
// licensing@syncfusion.com. Any infringement will be prosecuted under
6+
// applicable laws.
7+
#endregion
8+
using System;
9+
using System.Collections.Generic;
10+
using System.Linq;
11+
using System.Text;
12+
using System.Threading.Tasks;
13+
using Syncfusion.Data;
14+
using System.Data;
15+
using System.Collections;
16+
using System.ComponentModel;
17+
18+
namespace CustomSummarries
19+
{
20+
public class CustomSummary : ISummaryAggregate
21+
{
22+
public CustomSummary()
23+
{ }
24+
private string totalHours;
25+
public string TotalHours { get { return totalHours; } set { totalHours = value; } }
26+
public Action<IEnumerable, string, PropertyDescriptor> CalculateAggregateFunc()
27+
{
28+
return (items, property, pd) =>
29+
{
30+
var enumerableItems = items as IEnumerable<SalesByYear>;
31+
32+
//To check the summary format of the summary row.
33+
if (pd.Name == "TotalHours")
34+
{
35+
int total = 0;
36+
foreach (var item in items)
37+
{
38+
DataRowView dr = item as DataRowView;
39+
total += int.Parse(dr["Time in minutes"].ToString());
40+
}
41+
42+
this.totalHours = total / 60 + " Hours : " + total % 60 + " minutes";
43+
}
44+
};
45+
}
46+
}
47+
}

CS/CustomSummaryHelper.vb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Public Class CustomSummary
2+
Implements ISummaryAggregate
3+
4+
Public Sub New()
5+
End Sub
6+
7+
Private date As String
8+
9+
Public Property Date As String
10+
Get
11+
Return date
12+
End Get
13+
Set(ByVal value As String)
14+
date = value
15+
End Set
16+
End Property
17+
18+
Public Function CalculateAggregateFunc() As Action(Of IEnumerable, String, PropertyDescriptor) Implements ISummaryAggregate.CalculateAggregateFunc
19+
Return Sub(items, [property], pd)
20+
Dim enumerableItems = TryCast(items, IEnumerable(Of SalesByYear))
21+
22+
If pd.Name Is "Date" Then
23+
Dim t As TimeSpan = New TimeSpan(0, 0, 0)
24+
Dim ts As TimeSpan
25+
Dim dTime As DateTime
26+
27+
For Each item In items
28+
Dim dr As DataRowView = TryCast(item, DataRowView)
29+
30+
If DateTime.TryParse(dr("Date").ToString(), dTime) Then
31+
ts = New TimeSpan(dTime.Hour, dTime.Minute, 0)
32+
t = t.Add(ts)
33+
End If
34+
Next
35+
36+
Dim hours As Integer = CInt(t.TotalMinutes) / 60
37+
Dim min As Integer = CInt(t.TotalMinutes) Mod 60
38+
Me.Date = hours & ":" & min
39+
End If
40+
End Sub
41+
End Function
42+
End Class

CS/Form2.Designer.cs

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CS/Form2.cs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using Syncfusion.Data;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.ComponentModel;
5+
using System.Data;
6+
using System.Drawing;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
using System.Windows.Forms;
11+
using System.Collections;
12+
using Syncfusion.WinForms.DataGrid;
13+
14+
namespace CustomSummarries
15+
16+
{
17+
public partial class Form2 : Form
18+
{
19+
public Form2()
20+
{
21+
InitializeComponent();
22+
this.sfDataGrid.DataSource = this.CreateTable();
23+
this.sfDataGrid.TableSummaryRows.Add(new GridTableSummaryRow()
24+
{
25+
Name = "tableSumamryTrue",
26+
ShowSummaryInRow = false,
27+
Title = "Total : {TotalTime}",
28+
SummaryColumns = new System.Collections.ObjectModel.ObservableCollection<Syncfusion.Data.ISummaryColumn>()
29+
{
30+
new GridSummaryColumn()
31+
{
32+
Name = "TotalTime",
33+
CustomAggregate=new CustomSummary(),
34+
SummaryType=SummaryType.Custom,
35+
Format="Total time : {TotalHours}",
36+
MappingName="Time in minutes"
37+
},
38+
}
39+
});
40+
}
41+
42+
#region "Create DataTable"
43+
string[] name1 = new string[] { "John", "Peter", "Smith", "Jay", "Krish", "Mike" };
44+
string[] country = new string[] { "UK", "USA", "Pune", "India", "China", "England" };
45+
string[] city = new string[] { "Graz", "Resende", "Bruxelles", "Aires", "Rio de janeiro", "Campinas" };
46+
string[] scountry = new string[] { "Brazil", "Belgium", "Austria", "Argentina", "France", "Beiging" };
47+
DataTable dt = new DataTable();
48+
Random r = new Random();
49+
private DataTable CreateTable()
50+
{
51+
52+
dt.Columns.Add("Name");
53+
dt.Columns.Add("Id");
54+
dt.Columns.Add("Time in minutes", typeof(int));
55+
dt.Columns.Add("Country");
56+
dt.Columns.Add("Ship City");
57+
dt.Columns.Add("Ship Country");
58+
59+
60+
for (int l = 0; l < 100; l++)
61+
{
62+
System.Data.DataRow dr = dt.NewRow();
63+
dr[0] = name1[r.Next(0, 5)];
64+
dr[1] = "E" + r.Next(30);
65+
dr[2] = r.Next(30,60);
66+
dr[3] = country[r.Next(0, 5)];
67+
dr[4] = city[r.Next(0, 5)];
68+
dr[5] = scountry[r.Next(0, 5)];
69+
dt.Rows.Add(dr);
70+
}
71+
72+
return dt;
73+
}
74+
75+
#endregion
76+
}
77+
78+
}

0 commit comments

Comments
 (0)