Как сделать подсказку в datagrid

от admin

Add custom tooltip to row in DataGrid

I would like to customize my DataGrid to show a tooltip within the selected row, please see the mockup images below for a better idea of what I want to achieve.

As it is at the moment — Shows a single selected row:

How I would like — Shows the same row selected, now with tooltip:

enter image description here

  • My DataGrid uses Binding to the ViewModel.
  • Working with WPF & C# for Windows desktop.

I don’t really have any idea how to achieve this, so I’m open to any suggestions at all.

Add ToolTip for Columns and Headers

This article demonstrates how to set the tooltip of the gridview’s rows, columns and column headers.

If you are using the implicit styles approach for theming the controls with the NoXaml binaries, you need to base your styles on the default styles for the controls.

First you should add a GridView to the user control and bind it to some data.

Example 1: Bind RadGridView in XAML

ToolTip for Column’s Cells

You can check the source code below on how to set a ToolTip for a specific column. The ToolTip will use a DataTemplate with TextBlocks and will show information from the currently hovered row. The final result should look like this:

Telerik WPF DataGrid row tooltip

To achive that you can define a DataTemplate for the ToolTipTemplate property for the column.

Example 2: Setting ToolTipTemplate property

You can define the DataTemplate as a StaticResource and then directly assign the ToolTipTemplate property of the GridViewColumn.

The duration of the tooltip enabled with the ToolTipTemplate, set the ToolTipShowDuration property of the associated GridViewColumn element.

Example 3: Setting ToolTipShowDuration property

ToolTip for a Column’s Header Cell

To add a ToolTip to the header cells you can set a custom style to the HeaderCellStyle property. Or you can use the Header property of the column.

If you’re using the NoXAML binaries, you need to base your style on the GridViewHeaderCellStyle.

  • Predefine the HeaderCellStyle for the column.
Читать:
Pip install pytelegrambotapi как установить
Example 4: Setting custom style to the HeaderCellStyle property

You can define the DataTemplate as a StaticResource and then directly assign the HeaderCellStyle property of the GridViewColumn.

  • Predefine the Header for the column.
Example 5: Predefining the Header of the column

Telerik WPF DataGrid header tooltip

ToolTip for a GridViewRow

To add a ToolTip to the grid view row, you can create an implicit style that targets GridViewRow and set the ToolTipService.ToolTip attached property.

If you’re using the NoXAML binaries, you need to base your style on the GridViewRowStyle.

Добавить пользовательскую подсказку для строки в DataGrid

Я хотел бы настроить мой DataGrid, чтобы отобразить всплывающую подсказку в выбранной строке, пожалуйста, просмотрите изображения макета ниже для лучшего представления о том, чего я хочу достичь.

Как и в настоящий момент — показывает одну выбранную строку: Изображение 70552

Как мне хотелось бы — отображает ту же строку, которая теперь отображается с помощью всплывающей подсказки:

Подсказка для DataGridView. C# WinForms

Подскажите как сделать подсказку для DataGridView(ToolTip), если это возможно, чтобы при наведении курсора мыши, выводилось, к примеру, «Элементы матрицы».

Добавлял ToolTip к DataGridView и писал туда «Элементы матрицы», в надежде, что при наведении курсора появится подсказка — но нет, не появляется.

На каком-то форуме есть один вариант — для каждого столбца сделать ToolTipText — но этот вариант мне не подходит.

Ответы (2 шт):

Попробуй в datagridview.Rows[i].Tag загрузить информацию, после создай событие MouseEnter и тому подобное и через событие вызывай единый ToolTip и отправляй в качестве аргумента тот самый Tag

Для того, чтобы сделать подсказку для всей DataGridView, а не отдельных ячеек:

Похожие статьи