Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
I am using a DevExpress grid and I Would like to display a tooltip for each cell as I hover the cursor over it. I have written a code for that. It works fine and show tool-tips. But the tool tip is not changing while I'm moving the cursor on the same row. (Moving Horizontally). But if I leave the current row and come back, then the tool tip changes. Please advise me.

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


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

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

        if (hitInfo.InRow == false)
            return;

        if (hitInfo.Column == null)
            return;

        //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)
            return;

        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";
                            break;
                        case 2:
                            description = "guaranteed";
                            break;
                        case 3:
                            description = "texted";
                            break;
                        case 4:
                            description = "available";
                            break;
                        case 5:
                            description = "unavailable";
                            break;
                    }
                    //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();
                    e.Info.SuperTip.Setup(toolTipArgs);
                }
            }
        }
    }
}



Thanks for helping,
Kushan Randima.
Software Engineer
Davton Ltd
Posted
Updated 26-Oct-14 18:37pm
v2

e.Info.Object = hitInfo.HitTest.ToString() + hitInfo.RowHandle.ToString() + hitInfo.Column.FieldName; 
 
Share this answer
 
Hi,

I changed the code as follows. Now tool-tip is getting refresh for each cell in the grid-view.

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900