Skip to content

Commit 6e2fcab

Browse files
authored
Merge pull request #2 from SyncfusionExamples/ES-975464
ES-975464 - Resolve the ReadMe file length issue in this sample repository
2 parents 80e0259 + 62e3714 commit 6e2fcab

File tree

5 files changed

+104
-2
lines changed

5 files changed

+104
-2
lines changed

CustomizedMessageTip.png

10.8 KB
Loading

MessageTipForAllRowsAndColumns.png

9.09 KB
Loading
10 KB
Loading

MessageTipUsingQueryCellInfo.png

9.5 KB
Loading

README.md

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,104 @@
1-
# wpf-gridcontrol-input-message
2-
This repository contains the samples that demonstrates various options in input message feature of wpf gridcontrol.
1+
# WPF GridControl Input Message
2+
3+
This repository contains the samples that demonstrates various options in input message feature of [WPF GridControl](https://www.syncfusion.com/wpf-controls/excel-like-grid).
4+
5+
### Input Message Tip for row and column
6+
7+
The input message tip can be displayed for any row or column by setting the [ShowDataValidationTooltip](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridStyleInfo.html#Syncfusion_Windows_Controls_Grid_GridStyleInfo_ShowDataValidationTooltip) and the message tip can be customized by setting [DataValidationTooltip](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridStyleInfo.html#Syncfusion_Windows_Controls_Grid_GridStyleInfo_DataValidationTooltip) property.
8+
9+
``` csharp
10+
//Adding input message tip for specific row
11+
grid.Model.RowStyles[1].DataValidationTooltip = "Hello";
12+
grid.Model.RowStyles[1].ShowDataValidationTooltip = true;
13+
14+
//Adding input message tip for specific column
15+
grid.Model.ColStyles[1].DataValidationTooltip = "Hello";
16+
grid.Model.ColStyles[1].ShowDataValidationTooltip = true;
17+
```
18+
19+
![Set message tip for all the rows and columns](MessageTipForAllRowsAndColumns.png)
20+
21+
An another way to set the input message tip for specific row and column.
22+
23+
``` csharp
24+
//Add input message tip for specific row
25+
for (int i = 1; i <= 4; i++)
26+
{
27+
string comment = grid.Model[1, 0].CellValue + " :\nPopulation rate in " + grid.Model[1, i].ColumnIndex + " is " + grid.Model[1, i].CellValue;
28+
grid.Model[1, i].DataValidationTooltip = comment;
29+
grid.Model[1, i].ShowDataValidationTooltip = true;
30+
}
31+
32+
//Add input message tip for specific column
33+
for (int i = 1; i <= 4; i++)
34+
{
35+
string comment = grid.Model[i, 0].CellValue + " :\nPopulation rate in " + grid.Model[i, 2].RowIndex + " is " + grid.Model[i, 2].CellValue;
36+
grid.Model[i, 2].DataValidationTooltip = comment;
37+
grid.Model[i, 2].ShowDataValidationTooltip = true;
38+
}
39+
```
40+
41+
![Set message tip for specific row and column](MessageTipForSpecificRowsAndColumns.png)
42+
43+
### Set Input Message Tip using QueryCellInfo event
44+
45+
You can set the input message tip for specific cell or row or column by using [QueryCellInfo](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridModel.html#Syncfusion_Windows_Controls_Grid_GridModel_QueryCellInfo) event.
46+
47+
``` csharp
48+
private void Grid_QueryCellInfo(object sender, Syncfusion.Windows.Controls.Grid.GridQueryCellInfoEventArgs e)
49+
{
50+
e.Style.ShowDataValidationTooltip = true;
51+
52+
//Show message tip for specific cell
53+
if (e.Cell.RowIndex == 1 && e.Cell.ColumnIndex == 1)
54+
e.Style.DataValidationTooltip = e.Style.GridModel[1, 0].CellValue + ": \nPopulation rate in " + e.Style.ColumnIndex + " is " + e.Style.CellValue.ToString();
55+
56+
// Show message tip for row.
57+
if (e.Cell.ColumnIndex > 0 && e.Cell.RowIndex == 1)
58+
e.Style.DataValidationTooltip = e.Style.GridModel[1, 0].CellValue + ": \nPopulation rate in " + e.Style.ColumnIndex + " is " + e.Style.CellValue.ToString();
59+
60+
// Show message tip for column.
61+
if (e.Cell.RowIndex > 0 && e.Cell.ColumnIndex == 2)
62+
e.Style.DataValidationTooltip = e.Style.GridModel[e.Style.RowIndex, 0].CellValue + ": \nPopulation rate in " + e.Style.RowIndex + " is " + e.Style.CellValue.ToString();
63+
}
64+
```
65+
66+
![Defined message tip using QueryCellInfo event](MessageTipUsingQueryCellInfo.png)
67+
68+
### Customize the Input Message Tip
69+
70+
The input message tip can be customized by defining DataTemplate. The DataTemplate can be assigned to the [GridStyleInfo.DataValidationTooltipTemplateKey](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridStyleInfo.html#Syncfusion_Windows_Controls_Grid_GridStyleInfo_DataValidationTooltipTemplateKey) property. If you are using inputTextmessage1 then you need to assign template to its corresponding template key property namely `GridStyleInfo.DataValidationTooltipTemplateKey`.
71+
72+
[GridStyleInfo](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridStyleInfo.html) which holds cell information is the `DataContext` for data template of input message tip.
73+
74+
#### XAML
75+
76+
``` xml
77+
<Window.Resources>
78+
<DataTemplate x:Key="inputTextmessage1">
79+
<Border BorderBrush="Gray" BorderThickness="2.5" CornerRadius="5">
80+
<TextBlock Width="Auto" Height="Auto" HorizontalAlignment="Left" VerticalAlignment="Center" Background="LightBlue" FontSize="14" Foreground="Black" Text="{Binding DataValidationTooltip}" />
81+
</Border>
82+
</DataTemplate>
83+
</Window.Resources>
84+
```
85+
86+
#### C#
87+
88+
``` csharp
89+
// Set template key to a particular index
90+
grid.Model[1, 2].DataValidationTooltipTemplateKey = "inputTextmessage1";
91+
92+
// Using QueryCellInfo event
93+
private void Grid_QueryCellInfo(object sender, Syncfusion.Windows.Controls.Grid.GridQueryCellInfoEventArgs e)
94+
{
95+
if(e.Cell.RowIndex == 1 && e.Cell.ColumnIndex == 2)
96+
{
97+
e.Style.DataValidationTooltip = e.Style.GridModel[1, 0].CellValue + ": \nPopulation rate in " + e.Style.ColumnIndex + " is " + e.Style.CellValue.ToString();
98+
e.Style.ShowDataValidationTooltip = true;
99+
e.Style.DataValidationTooltipTemplateKey = "inputTextmessage1";
100+
}
101+
}
102+
```
103+
104+
![Gridcontrol with customized message tipi](CustomizedMessageTip.png)

0 commit comments

Comments
 (0)