We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ToolTip on header

Thread ID:

Created:

Updated:

Platform:

Replies:

142022 Jan 15,2019 11:11 AM UTC Jan 23,2019 01:06 PM UTC WPF 3
loading
Tags: GridDataControl
Petr Bahník
Asked On January 15, 2019 11:11 AM UTC

Is there a way to display tooltip on grid header?
HeaderText is wider then Width of column, so it would be fine to show it as tooltip

Arulraj A [Syncfusion]
Replied On January 17, 2019 10:07 AM UTC

Hi Petr, 
 
Thank you for contacting Syncfusion support. 
 
To show the tooltip for column HeaderText you can set the Style.ShowTooltip property true and set the text for the first row which is the header row. 
 
<syncfusion:GridDataControl x:Name="dataGrid" Grid.Column="0" 
                            AutoPopulateColumns="False" 
                            ShowTooltips="True" 
                            AutoPopulateRelations="False"    
                            ColumnSizer="Star" 
                            ItemsSource="{Binding CustomerInfo}" 
                            ShowAddNewRow="False" 
                            ShowGroupDropArea="True"> 
 
public class SortColumnBehavior : Behavior<GridDataControl> 
{ 
    GridDataControl dataControl = null; 
    /// <summary> 
    /// Called when [attached]. 
    /// </summary> 
    protected override void OnAttached() 
    { 
        dataControl = this.AssociatedObject as GridDataControl;    
        dataControl.Model.QueryCellInfo += Model_QueryCellInfo; 
    } 
 
    private void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) 
    { 
        if(e.Cell.RowIndex == 0) 
        { 
            e.Style.ShowTooltip =true; 
            var column = dataControl.VisibleColumns[e.Cell.ColumnIndex]; 
            e.Style.ToolTip = column.HeaderText; 
        } 
    } 
 
    protected override void OnDetaching() 
    { 
        dataControl.Model.QueryCellInfo -= Model_QueryCellInfo; 
    } 
} 
 
Please find the sample from the below location. 
 
Arulraj A 


Petr Bahník
Replied On January 18, 2019 11:16 AM UTC

Hello Arulraj,

thank you for your answer. It helped me, with slight modification it works for me.
There is probably problem with grids, which have more columns than VisibleColumns.Count.
I use in some cases DetailsViewTemplate , which causes creating column at first position, which is not in VisibleColumns, so I had to modify ModelQueryCellInfo method like this to prevent System.ArgumentOutOfRangeException:

 private void ModelQueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
        {
            if (e.Cell.RowIndex == 0)
            {
                var hasDetailsViewTemplate = _dataControl.DetailsViewTemplate != null;
                var columnIndex = hasDetailsViewTemplate ? e.Cell.ColumnIndex - 1 : e.Cell.ColumnIndex;                
                if (columnIndex < _dataControl.VisibleColumns.Count && columnIndex >= 0)
                {
                    e.Style.ShowTooltip = true;
                    var column = _dataControl.VisibleColumns[columnIndex];
                    e.Style.ToolTip = column.HeaderText;
                }
            }
        }

But I feel it will not work when existing some other kind of not visible columns.
Is there some better way?

And please try to drag and drop column in your sample (as written in it), you will get also exception same as my for grid with DetailsViewTemplate.


Sathiyathanam Jeyakumar [Syncfusion]
Replied On January 23, 2019 01:06 PM UTC

Hi Petr, 
 
Thanks for your update. 

We have checked the reported “Tooltip not shown” issue from our end with the detailsview template sample, but we unable to reproduce the issue with the given code snippets. And also, we don’t get any exception while dragging the columns.
 
 
To show the tooltips for GridDataControl you must enable the ShowToolTips as true for GridDataControl same like as below, 
<syncfusion:GridDataControl x:Name="dataGrid" 
                            Grid.Row="0" 
                            AutoPopulateColumns="False" 
                            AutoPopulateRelations="False" 
                            AllowDragColumns="True" 
                            ColumnSizer="None" 
                            ShowTooltips="True" 
 
 
Please find the testing sample from the below location. 
 
Regards, 
Sathiyathanam 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;