Show tooltips for DevExpress grid cells

I am using the "DevExpress" grid and I would like to display a tooltip for each cell when I hover over it. I wrote some code for this. It works great and shows hints. But the tooltip doesn't change as long as I move the cursor on the same line. (Move horizontally). But if I leave the current line and return, then the prompt changes. Please tell me.

Here is the code for "toolTipController" (I copied the whole method for better understanding)

private void toolTipController1_GetActiveObjectInfo(object sender, ToolTipControllerGetActiveObjectInfoEventArgs e)
        bool validColumn = false;
        if (e.SelectedControl != gridControl1)

        GridHitInfo hitInfo = gridView1.CalcHitInfo(e.ControlMousePosition);

        if (hitInfo.InRow == false)

        if (hitInfo.Column == null)

        //concern only the following fields
        if (hitInfo.Column.FieldName == "Monday" || hitInfo.Column.FieldName == "Tuesday" || hitInfo.Column.FieldName == "Wednesday" || hitInfo.Column.FieldName == "Thursday" || hitInfo.Column.FieldName == "Friday")
            validColumn = true;

        if (!validColumn)

        string toolTip = string.Empty;
        SuperToolTipSetupArgs toolTipArgs = new SuperToolTipSetupArgs();
        toolTipArgs.Title.Text = string.Empty;

        //Get the data from this row
        string columnCaption = hitInfo.Column.Caption;
        DateTime dateOK = new DateTime(2000,1,1);
        if (DateTime.TryParse(columnCaption, out dateOK))

            DateTime date = DateTime.Parse(columnCaption);
            int row = hitInfo.RowHandle;
            long teacherID = long.Parse(gridView1.GetRowCellValue(row, "TeacherID").ToString());

            GuaranteedDay gDay = db.GuaranteedDays.Where(p => p.Date == date && p.TeacherID == teacherID && p.Type == 5).FirstOrDefault();
            if (gDay != null)
                if (gDay.Note != string.Empty)
                    //Set description for the tool-tip
                    string description = string.Empty;
                    int type = gDay.Type;
                    switch (type)
                        case 1:
                            description = "guarantee offered";
                        case 2:
                            description = "guaranteed";
                        case 3:
                            description = "texted";
                        case 4:
                            description = "available";
                        case 5:
                            description = "unavailable";
                    //Add Notes & description for the tool-tip
                    toolTip = "Notes : " + gDay.Note + "\nDescription : " + description;

                    string BodyText = toolTip;

                    toolTipArgs.Contents.Text = BodyText;
                    e.Info = new ToolTipControlInfo();
                    e.Info.Object = hitInfo.HitTest.ToString() + hitInfo.RowHandle.ToString(); 
                    e.Info.ToolTipType = ToolTipType.SuperTip;
                    e.Info.SuperTip = new SuperToolTip();


Thank you for your help, Kushan Randima.


source to share

1 answer

But the tool tip does not change while I move the cursor on the same line. (Move horizontally). But if I leave the current line and return, then the prompt changes.

I see that you passed the same "hit object" for any cells on the current line:

e.Info.Object = hitInfo.HitTest.ToString() + hitInfo.RowHandle.ToString();  


To accomplish your task, you must pass different hit objects for different cells:

e.Info.Object = hitInfo.HitTest.ToString() + hitInfo.RowHandle.ToString() + hitInfo.Column.FieldName;  




All Articles