【问题标题】:How to increase ToolTip display time?如何增加 ToolTip 显示时间?
【发布时间】:2012-08-14 12:07:24
【问题描述】:

我有一个 GridView,在其 RowDataBound 事件中,我将 ToolTip 分配如下:

protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
    try
    {
        if (gv.HeaderRow != null && e.Row.RowType == DataControlRowType.DataRow)
        {  
            e.Row.ToolTip = "Remarks: " + ((Label)e.Row.FindControl("lblRemarks")).Text;
        }
    }
    catch (Exception ex)
    {
        BussinessLayer.RIBOException.Instance.HandleMe(this, ex);
    }
}

这里,我想延长ToolTip的显示时间。 如何做到这一点?

【问题讨论】:

标签: c# asp.net visual-studio-2008 time tooltip


【解决方案1】:

您需要使用ToolTipService,特别是ShowDuration attached property

设置工具提示后,您应该能够执行以下操作:

ToolTipService.ShowDuration(e.Row, 10000)

【讨论】:

  • ToolTipService 用于 WPF,并且该问题使用 ASP.NET 标记
  • 当我输入 ToolTipService 时,智能感知没有出现。为什么以及如何获得此属性?我需要使用任何命名空间吗?
  • @thevan - 为什么在这对您不起作用并且对 ASP.NET 中的其他任何人都不起作用时,它被标记为已接受?
  • 已经有一段时间了,但我相信这个问题在第一次发布时被错误地标记为 WPF。我不知道为什么它被接受了......
  • 为了记录,如果我们在谈论 WPF,持续时间以毫秒为单位。
【解决方案2】:

设置 ToolTipService.ShowDuration 属性。

【讨论】:

  • ToolTipService 用于 WPF,并且该问题使用 ASP.NET 标记
  • 当我输入 ToolTipService 时,智能感知没有出现。为什么以及如何获得此属性?我需要使用任何命名空间吗?
  • 在 asp.net 中,您必须在 javascript 中实现自己的工具提示,并在此处引入延迟属性如何做到这一点javascript.about.com/library/bltip1.htm
【解决方案3】:
<Button x:Name="btnHelp" ToolTip="For new paragraph : press Enter &#x0a;For new line : press Shift+Enter">
 <ToolTipService.ShowDuration>15000</ToolTipService.ShowDuration>
</Button>

【讨论】:

    【解决方案4】:

    这有效,提供间距和其他格式选项。上述接受的选项不起作用

    <div runat="server" class="tooltip" id="divHowTo" style="display: inline-block; width:75px" data-tip="If you have problems: &#013;&#010;
            1.) Enter a users id &#013;&#010;
            2.) Choose a corresponding domain for the pin  &#013;&#010;
            3.) Verify resolved name is correct  &#013;&#010;
            4.) (If adding) Browse for Picture (jpg/png format) (square resolution) (240px X 240px or larger)  &#013;&#010;
            5.) Choose a button to add or delete or view or save or clear " >
        <asp:Image ID="imgHowTo" runat="server" ImageUrl="Images/howTo1s.jpg"  Height="73px" Width="73px"/>
    
        </div>
    

    与(在之间)的类

        .tooltip {
                    display:inline-block;
                    width:64px;
                    height:64px;
                    position:relative;
                    margin:25px;
                    background-repeat: no-repeat;
                    background-position:50% 50%;
                    background-size:100%;
                    text-align:center;
                    line-break:auto;
                    white-space:pre-line;
                }
        .tooltip:hover:after {
                    display:inline-block;
                    position:absolute;
                    top:-25px;
                    left:50%;
                    height:400px;
                    content: attr(data-tip);
                    font:bold 10px/14px Arial, sans-serif;
                    background:#f0f0f0;
                    color:#333;
                    white-space:pre-line;
                    border:1px solid #665;
                    padding:2px 4px;
                    width:150px;
                    margin:0 0 0 -75px;
                    border-radius:3px;
                    line-break:auto;
                }
        .tooltip:hover:before {
                    border-top: 10px solid #665;
                    border-top: 10px solid #665;
                    margin-top: 5px;
                    content: "";
                    position: absolute;
                    border-left: 5px solid transparent;
                    border-right: 10px solid transparent;
                    top:-15px;
                    left: 50%;
                    margin-left: -10px;
                    line-break:auto;
                    white-space:pre-line;
                }
    

    【讨论】:

      【解决方案5】:

      在 XAML 中你可以这样做:

      <MyWpfElement ... ToolTipService.ShowDuration="60000" />
      

      该值以毫秒为单位。示例代码最多显示一分钟的工具提示。

      【讨论】:

        猜你喜欢
        • 2020-11-02
        • 2020-09-01
        • 2016-12-24
        • 1970-01-01
        • 2019-07-13
        • 1970-01-01
        • 2012-12-05
        • 1970-01-01
        • 2020-09-14
        相关资源
        最近更新 更多