-
Notifications
You must be signed in to change notification settings - Fork 0
ES-975464 - Resolve the ReadMe file length issue in this sample repository #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,148 @@ | ||
| # WPF-GridControl-ToolTip | ||
| This repository contains the sample which shows add or remove the tooltip to a specific cell or row or column in WPF GridControl. | ||
| # WPF GridControl ToolTip | ||
|
|
||
| This repository contains the sample which shows add or remove the tooltip to a specific cell or row or column in [WPF GridControl](https://www.syncfusion.com/wpf-controls/excel-like-grid). | ||
|
|
||
| ### ToolTip for row and column | ||
|
|
||
| ToolTip can be displayed for any row or column by setting the [ShowToolTip](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridStyleInfo.html#Syncfusion_Windows_Controls_Grid_GridStyleInfo_ShowTooltip) and ToolTip text can be customized by setting the [ToolTip](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridStyleInfo.html#Syncfusion_Windows_Controls_Grid_GridStyleInfo_ToolTip). | ||
|
|
||
| ``` csharp | ||
| //Adding tooltip to the specific row | ||
| gridcontrol.Model.RowStyles[1].ToolTip = "First row"; | ||
| gridcontrol.Model.RowStyles[1].ShowTooltip = true; | ||
|
|
||
| //Adding tooltip to the specific column | ||
| gridcontrol.Model.ColStyles[1].ToolTip = "First column"; | ||
| gridcontrol.Model.ColStyles[1].ShowTooltip = true; | ||
| ``` | ||
|
|
||
|  | ||
|
|
||
| ### Set ToolTip in QueryCellInfo event | ||
|
|
||
| You can set the ToolTip to a specific cell or row or column by using the [QueryCellInfo](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridControlBase.html#Syncfusion_Windows_Controls_Grid_GridControlBase_QueryCellInfo) event. | ||
|
|
||
| ``` csharp | ||
| private void Gridcontrol_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) | ||
| { | ||
| e.Style.ShowTooltip = true; | ||
| //Show tooltip for specific index | ||
| if (e.Cell.RowIndex == 1 && e.Cell.ColumnIndex == 1) | ||
| e.Style.ToolTip = " Grid (" + gridcontrol.Model[1, 1].CellValue +") "; | ||
| // Show tooltip for row. | ||
| if (e.Cell.ColumnIndex > 0 && e.Cell.RowIndex == 5) | ||
| e.Style.ToolTip = " Row " + "(" + e.Cell.RowIndex + "," + e.Cell.ColumnIndex + ") "; | ||
| // Show tooltip for column. | ||
| if (e.Cell.RowIndex > 0 && e.Cell.ColumnIndex == 4) | ||
| e.Style.ToolTip = " Column " + "(" + e.Cell.RowIndex + "," + e.Cell.ColumnIndex + ") "; | ||
| } | ||
| ``` | ||
|
|
||
|  | ||
|
|
||
| ### Hide ToolTip for disabled cell | ||
|
|
||
| You can disable the cell by setting `Enabled` property to `false`. If you want to hide the tooltip for this disabled cell, you need to set the [ShowToolTip](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridStyleInfo.html#Syncfusion_Windows_Controls_Grid_GridStyleInfo_ShowTooltip) property to `false`. | ||
|
|
||
| ``` csharp | ||
| gridcontrol.Model[1, 1].Enabled = false; | ||
| gridcontrol.Model[1, 1].ToolTip = " Grid (" + gridcontrol.Model[1, 1].CellValue + ") "; | ||
| gridcontrol.Model[1, 1].ShowTooltip = false; | ||
|
|
||
| //Using QueryCellInfo | ||
| private void Gridcontrol_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) | ||
| { | ||
| if (e.Cell.RowIndex == 1 && e.Cell.ColumnIndex == 1) | ||
| { | ||
| e.Style.Enabled = false; | ||
| e.Style.ToolTip = " Grid (" + e.Cell.RowIndex + "," + e.Cell.ColumnIndex + ") "; | ||
| e.Style.ShowTooltip = false; | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Customize the ToolTip | ||
|
|
||
| The tooltip appearance can be customized by defining DataTemplate. The DataTemplate can be assigned to the [GridStyleInfo.ToolTipTemplateKey](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridStyleInfo.html#Syncfusion_Windows_Controls_Grid_GridStyleInfo_TooltipTemplateKey) or [GridStyleInfo.ToolTipTemplate](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridStyleInfo.html#Syncfusion_Windows_Controls_Grid_GridStyleInfo_TooltipTemplate) property. If you are using tooltipTemplate1 then you need to assign template to its corresponding template key property namely GridStyleInfo.ToolTipTemplate or GridStyleInfo.ToolTipTemplateKey. | ||
|
|
||
| [GridStyleInfo](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridStyleInfo.html) which holds cell information is the DataContext for data template of ToolTip. | ||
|
|
||
| #### Using ToolTipTemplateKey | ||
|
|
||
| ##### XAML | ||
|
|
||
| ``` xml | ||
| <Window.Resources> | ||
| <DataTemplate x:Key="tooltipTemplate1"> | ||
| <Border Name="Border" | ||
| Background="Green" | ||
| BorderBrush="Black" | ||
| BorderThickness="1" Width="60" Height="20" | ||
| CornerRadius="0"> | ||
| <TextBlock Background="Transparent" Text="{Binding Path=ToolTip}" Padding="2" /> | ||
| </Border> | ||
| </DataTemplate> | ||
| </Window.Resources> | ||
| ``` | ||
|
|
||
| ##### C# | ||
|
|
||
| ``` csharp | ||
| //Set the template key to a particular index | ||
| gridcontrol.Model[1, 1].TooltipTemplateKey = "tooltipTemplate1"; | ||
|
|
||
| //Using QueryCellInfo event | ||
| private void Gridcontrol_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) | ||
| { | ||
| if (e.Cell.RowIndex == 1 && e.Cell.ColumnIndex == 1) | ||
| { | ||
| e.Style.ToolTip = " Grid (" + e.Cell.RowIndex + "," + e.Cell.ColumnIndex + ") "; | ||
| e.Style.TooltipTemplateKey = "tooltipTemplate1"; | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| #### Using ToolTipTemplate | ||
|
|
||
| ##### XAML | ||
|
|
||
| ``` xml | ||
| <Window.Resources> | ||
| <DataTemplate x:Key="tooltipTemplate1"> | ||
| <Border Name="Border" | ||
| Background="Green" | ||
| BorderBrush="Black" | ||
| BorderThickness="1" Width="60" Height="20" | ||
| CornerRadius="0"> | ||
| <TextBlock Background="Transparent" Text="{Binding Path=ToolTip}" Padding="2" /> | ||
| </Border> | ||
| </DataTemplate> | ||
| </Window.Resources> | ||
| ``` | ||
|
|
||
| ##### C# | ||
|
|
||
| ``` csharp | ||
| //Set the template key to a particular index | ||
| gridcontrol.Model[1, 1].TooltipTemplate = (DataTemplate)this.Resources["tooltipTemplate1"]; | ||
|
|
||
| //Using QueryCellInfo event | ||
| private void Gridcontrol_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) | ||
| { | ||
| if (e.Cell.RowIndex == 1 && e.Cell.ColumnIndex == 1) | ||
| { | ||
| e.Style.ToolTip = " Grid (" + e.Cell.RowIndex + "," + e.Cell.ColumnIndex + ") "; | ||
| e.Style.TooltipTemplate = (DataTemplate)this.Resources["tooltipTemplate1"]; | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
|  | ||
|
|
||
| ### Remove the ToolTip | ||
|
|
||
| The `ResetValue` method is used to remove the ToolTip for any cell or row or column in GridControl and to reset the ToolTip value to the default values. | ||
|
|
||
| ``` csharp | ||
| gridcontrol.Model[1, 1].ResetValue(GridStyleInfoStore.ToolTipProperty); | ||
| ``` | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.