鼠标悬停在Gridview中的工具提示.--需要帮助 [英] Tool tip in Gridview on Mouse Over.--- Need Help
问题描述
你好,朋友们,
在我的项目中,我有gridview.我需要鼠标悬停"上的工具提示".
在那个Gridview中,我有一个名为DAYS的columnName,其中有
天数
=================
M T W Th F S Su
当用户将鼠标保持在gridview单元上时,它必须显示工具提示为:
M为星期一
T表示星期二
W为星期三
如星期四
F代表星期五
S为星期六
Su as Sunday
这是我的代码
Hello hi frnds,
In my project i have gridview. I need TOOL tip on Mouse Over.
In that Gridview i have a columnName called DAYS in which i have
DAYS
=================
M T W Th F S Su
when the users keeps the mouse on gridview cell, it must show Tool tip as :
M as Monday
T as Tuesday
W as Wednesday
Th as Thursday
F as Friday
S as Saturday
Su as Sunday
This is my code
foreach (GridViewRow item in GridView1.Rows)
{
Collapse | Copy Code
string Days = item.Cells[9].Text;
Days = Days.Substring(0, 1);
if (Days == "M")
{
item.Cells[9].ToolTip = "Monday";
}
else if (Days == "T")
{
item.Cells[9].ToolTip = "Tuesday";
}
}
但是这些代码无法解决.
请任何人能帮助我.我从1周开始尝试.
谢谢,
But these code unable to work out.
Please can anyone help me. am Trying Since from 1 week.
Thanks,
推荐答案
已经回答了.
www.codeproject.com/Questions/67397/如何在鼠标上的网格视图中显示工具提示文本
Hi,
Its already answered.
www.codeproject.com/Questions/67397/How-to-show-tooltip-text-in-gridview-row-on-mouseo
GridView
的RowDataBound
事件可用于设置ToolTips
如下:
TheRowDataBound
event of theGridView
can be used to setup theToolTips
as follows:
//Create an array of Day Names
string[] dayNames = Enum.GetNames(typeof(DayOfWeek));
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {
if (e.Row.RowType == DataControlRowType.DataRow) {
string day = e.Row.Cells[9].Text;
e.Row.Cells[9].ToolTip = dayNames.FirstOrDefault(n => n.StartsWith(day == "T" ? "Tu" : day == "S" ? "Sa" : day)) ?? "";
}
}
确保您输入的是此代码RowDataBound
www.codeproject.com/Answers/375432/Gridview-Cells-Tool-tip-Text [^ ]
然后放置断点并调试代码.
最好的问候
米特瓦里(M.Mitwalli)
Hi ,
Make sure you are putting this codeRowDataBound
www.codeproject.com/Answers/375432/Gridview-Cells-Tool-tip-Text[^]
And Put break point and debug the code .
Best Regards
M.Mitwalli
这篇关于鼠标悬停在Gridview中的工具提示.--需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!