显示DevExpress网格单元的工具提示

我正在使用“ DevExpress”网格,当我将光标悬停在其上方时,我想显示每个单元格的工具提示.我已经为此编写了代码.它工作正常,并显示工具提示.但是,当我在同一行上移动光标时,工具提示没有更改. (水平移动).但是,如果我离开当前行并返回,则工具提示会更改.请建议我.

这是“ toolTipController”的代码(为了更好的理解,我复制了整个方法)

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);
                }
            }
        }
    }
}

感谢您的帮助,
库山兰迪玛.

解决方法:

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.

我看到您为当前行内的任何单元格传递了相同的“命中对象”:

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

要完成您的任务,您应该为不同的单元格传递不同的“命中对象”:

e.Info.Object = hitInfo.HitTest.ToString() + hitInfo.RowHandle.ToString() + hitInfo.Column.FieldName;  
上一篇:JQuery Validation + JQuery Validation Bootstrap Tooltip


下一篇:JavaScript的 – 提示内部的任何HTML标签会导致基本工具提示关闭悬停