Skip to content

Commit 626237d

Browse files
authored
Merge pull request #1 from Backiaraj/inputmessage
Added sample for input message tip feature in WPF GridControl
2 parents eaa28da + 19bdbd4 commit 626237d

39 files changed

+1793
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28307.960
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gridcontrol-input-message-tip", "gridcontrol-input-message-tip\gridcontrol-input-message-tip.csproj", "{6E5A746D-6DBF-4681-B4E3-428503E7C137}"
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+
{6E5A746D-6DBF-4681-B4E3-428503E7C137}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{6E5A746D-6DBF-4681-B4E3-428503E7C137}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{6E5A746D-6DBF-4681-B4E3-428503E7C137}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{6E5A746D-6DBF-4681-B4E3-428503E7C137}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {4E9F99BB-5E4F-40C7-BF69-1D2AE26BA079}
24+
EndGlobalSection
25+
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="gridcontrol_input_message_tip.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:gridcontrol_input_message_tip"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace gridcontrol_input_message_tip
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Window x:Class="gridcontrol_input_message_tip.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:gridcontrol_input_message_tip"
7+
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
8+
mc:Ignorable="d"
9+
Title="MainWindow" Height="450" Width="800">
10+
<Window.Resources>
11+
<DataTemplate x:Key="TextBlockTemplate1">
12+
<TextBlock HorizontalAlignment="Center"
13+
VerticalAlignment="Center"
14+
FontSize="14"
15+
Text="{Binding CellBoundValue}"></TextBlock>
16+
</DataTemplate>
17+
</Window.Resources>
18+
<Grid>
19+
<syncfusion:GridControl Name="grid" Margin="10,20,0,0" syncfusion:GridTooltipService.ShowTooltips="True" />
20+
</Grid>
21+
</Window>
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
using Syncfusion.Windows.Controls.Grid;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using System.Windows;
9+
using System.Windows.Controls;
10+
using System.Windows.Data;
11+
using System.Windows.Documents;
12+
using System.Windows.Input;
13+
using System.Windows.Media;
14+
using System.Windows.Media.Imaging;
15+
using System.Windows.Navigation;
16+
using System.Windows.Shapes;
17+
18+
namespace gridcontrol_input_message_tip
19+
{
20+
/// <summary>
21+
/// Interaction logic for MainWindow.xaml
22+
/// </summary>
23+
public partial class MainWindow : Window
24+
{
25+
DataTable dataTable;
26+
Random random;
27+
public MainWindow()
28+
{
29+
InitializeComponent();
30+
Width = 1000;
31+
Height = 600;
32+
this.LoadData();
33+
grid.Width = 700;
34+
grid.Height = 400;
35+
grid.Model.HeaderStyle.Borders.All = new System.Windows.Media.Pen(System.Windows.Media.Brushes.LightGray, 1);
36+
grid.Model.RowCount = dataTable.Rows.Count;
37+
grid.Model.ColumnCount = dataTable.Columns.Count;
38+
grid.Model.RowHeights.DefaultLineSize = 30;
39+
grid.Model.ColumnWidths.DefaultLineSize = 115;
40+
grid.Model.ColumnWidths[0] = 115;
41+
grid.QueryCellInfo += Grid_QueryCellInfo;
42+
grid.Model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.DblClickOnCell;
43+
44+
//Add input message tip for specific row
45+
for (int i = 1; i <= 4; i++)
46+
{
47+
string comment = grid.Model[1, 0].CellValue + " :\nPopulation rate in " + grid.Model[1, i].ColumnIndex + " is " + grid.Model[1, i].CellValue;
48+
grid.Model[1, i].DataValidationTooltip = comment;
49+
grid.Model[1, i].ShowDataValidationTooltip = true;
50+
}
51+
52+
//Add input message tip for specific column
53+
for (int i = 1; i <= 4; i++)
54+
{
55+
string comment = grid.Model[i, 0].CellValue + " :\nPopulation rate in " + grid.Model[i, 2].RowIndex + " is " + grid.Model[i, 2].CellValue;
56+
grid.Model[i, 2].DataValidationTooltip = comment;
57+
grid.Model[i, 2].ShowDataValidationTooltip = true;
58+
}
59+
GridTooltipService.SetShowTooltips(grid, true);
60+
}
61+
62+
private void Grid_QueryCellInfo(object sender, Syncfusion.Windows.Controls.Grid.GridQueryCellInfoEventArgs e)
63+
{
64+
GridCommentStyleInfo gridStyleInfo = new GridCommentStyleInfo();
65+
if (e.Style.RowIndex == 0 || e.Style.ColumnIndex == 0)
66+
{
67+
e.Style.CellType = "DataBoundTemplate";
68+
e.Style.CellItemTemplateKey = "TextBlockTemplate1";
69+
}
70+
if (e.Style.RowIndex == 0)
71+
e.Style.CellValue = dataTable.Columns[e.Style.ColumnIndex];
72+
else
73+
e.Style.CellValue = dataTable.Rows[e.Style.RowIndex][e.Style.ColumnIndex];
74+
}
75+
76+
public void LoadData()
77+
{
78+
dataTable = new DataTable();
79+
dataTable.Columns.Add(new DataColumn("Country"));
80+
dataTable.Columns.Add(new DataColumn("2005"));
81+
dataTable.Columns.Add(new DataColumn("2006"));
82+
dataTable.Columns.Add(new DataColumn("2007"));
83+
dataTable.Columns.Add(new DataColumn("2008"));
84+
random = new Random();
85+
86+
var row = dataTable.NewRow();
87+
row["Country"] = "USA";
88+
LoadCellValues(row);
89+
dataTable.Rows.Add(row);
90+
91+
row = dataTable.NewRow();
92+
row["Country"] = "India";
93+
LoadCellValues(row);
94+
dataTable.Rows.Add(row);
95+
96+
row = dataTable.NewRow();
97+
row["Country"] = "China";
98+
LoadCellValues(row);
99+
dataTable.Rows.Add(row);
100+
101+
row = dataTable.NewRow();
102+
row["Country"] = "Japan";
103+
LoadCellValues(row);
104+
dataTable.Rows.Add(row);
105+
106+
row = dataTable.NewRow();
107+
row["Country"] = "UK";
108+
LoadCellValues(row);
109+
dataTable.Rows.Add(row);
110+
}
111+
112+
public void LoadCellValues(DataRow row)
113+
{
114+
for (int i = 1; i <= 4; i++)
115+
{
116+
row[i] = ((double)random.Next(2, 18)).ToString() + "%";
117+
}
118+
}
119+
}
120+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System.Reflection;
2+
using System.Resources;
3+
using System.Runtime.CompilerServices;
4+
using System.Runtime.InteropServices;
5+
using System.Windows;
6+
7+
// General Information about an assembly is controlled through the following
8+
// set of attributes. Change these attribute values to modify the information
9+
// associated with an assembly.
10+
[assembly: AssemblyTitle("gridcontrol-input-message-tip")]
11+
[assembly: AssemblyDescription("")]
12+
[assembly: AssemblyConfiguration("")]
13+
[assembly: AssemblyCompany("")]
14+
[assembly: AssemblyProduct("gridcontrol-input-message-tip")]
15+
[assembly: AssemblyCopyright("Copyright © 2020")]
16+
[assembly: AssemblyTrademark("")]
17+
[assembly: AssemblyCulture("")]
18+
19+
// Setting ComVisible to false makes the types in this assembly not visible
20+
// to COM components. If you need to access a type in this assembly from
21+
// COM, set the ComVisible attribute to true on that type.
22+
[assembly: ComVisible(false)]
23+
24+
//In order to begin building localizable applications, set
25+
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
26+
//inside a <PropertyGroup>. For example, if you are using US english
27+
//in your source files, set the <UICulture> to en-US. Then uncomment
28+
//the NeutralResourceLanguage attribute below. Update the "en-US" in
29+
//the line below to match the UICulture setting in the project file.
30+
31+
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32+
33+
34+
[assembly: ThemeInfo(
35+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36+
//(used if a resource is not found in the page,
37+
// or application resource dictionaries)
38+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39+
//(used if a resource is not found in the page,
40+
// app, or any theme specific resource dictionaries)
41+
)]
42+
43+
44+
// Version information for an assembly consists of the following four values:
45+
//
46+
// Major Version
47+
// Minor Version
48+
// Build Number
49+
// Revision
50+
//
51+
// You can specify all the values or you can default the Build and Revision Numbers
52+
// by using the '*' as shown below:
53+
// [assembly: AssemblyVersion("1.0.*")]
54+
[assembly: AssemblyVersion("1.0.0.0")]
55+
[assembly: AssemblyFileVersion("1.0.0.0")]

input-message-row-and-column/gridcontrol-input-message-tip/Properties/Resources.Designer.cs

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

0 commit comments

Comments
 (0)