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

编程入门 行业动态 更新时间:2024-10-25 18:29:18
本文介绍了显示DevExpress网格单元的工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用一个DevExpress网格,我想显示工具提示 for 每个单元格 我将光标悬停在它上面。我为编写了一个代码。它工作正常并显示工具提示。但是工具提示 没有改变而我' m将光标移动到同一行。 (水平移动)。但如果我离开当前行并返回,则工具提示会发生变化。请建议我。 这是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; //仅涉及以下字段 if(hitInfo.Column.FieldName ==Monday|| hitInfo.Column.FieldName ==Tuesday|| hitInfo.Column.FieldName ==星期三|| 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; //从这一行获取数据 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) { //设置工具提示的描述 string description = string.Empty; int type = gDay.Type; 开关(类型) {案例1: description =保证提供; 休息; 案例2: description =保证; 休息; 案例3: description =texted; 休息; 案例4: description =available; 休息; 案例5: description =不可用; 休息; } //添加备注&工具提示说明 toolTip =注意:+ 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); } } } } }

感谢您的帮助, Kushan Randima。 软件工程师 Davton Ltd

解决方案

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

我按如下方式更改了代码。现在,工具提示正在为网格视图中的每个单元格进行刷新。

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

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

解决方案

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

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;

更多推荐

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

本文发布于:2023-11-22 23:22:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619315.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   单元   提示   工具   DevExpress

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!