不知道有什么人上过btChina,把鼠标放在一个链接或控件上面,他显示的toolTip中是带有图片及链接的,请问在C#下怎么使得ToolTIp带有这咱效果呢? 
我自己做了一个模拟的半透明背景的窗体,可以达到toolTip的透明效果,但是每次如果直接让他显示时,他总是会躲在其他窗体的下面看不见,只有将他最小化再最大化才能显示出来,如果第一个问题没有办法,那有没有人能让这个模拟的窗体一visiable=true就显示在最顶层上呢? 我试过topmost=true; .show();.bringtofront(),但是就没用,还是会别的窗体下面,当然,在显示之前已经把其他窗体的topmost=false了;

解决方案 »

  1.   

    建议楼主先学好html....楼下是否赞同?
      

  2.   

    直接继承ToolTip,自己做一个嘛
      

  3.   

    我做的是Winform程序,不是网页应用程序我刚学这东西,对于继承一个控件来说还不是很明白,所以可以的话,麻烦详细介绍一下 谢谢~
      

  4.   

    我刚想继承ToolTip,然后想在其属性里的container.add(picturebox1),可是会发生Container未将对象引用实例,所以不知道怎么做下去了,有谁能帮帮我吗?
      

  5.   

    =.=如果你用WPF的话会发现好简单。是真的好简单
      

  6.   

    toolTip是可以被重画的。你可以设置如下属性为True:ToolTip.OwnerDraw 属性 下面的代码示例演示如何以所有者描述模式绘制 ToolTip。此示例创建一个 ToolTip 并将其与 Form 上的三个 Button 控件相关联。此示例将 OwnerDraw 属性设置为 true 并处理 Draw 事件。在 Draw 事件处理程序中,是以不同方式自定义绘制 ToolTip 的,具体情况取决于 ToolTip 为其显示的按钮(由 DrawToolTipEventArgs.AssociatedControl 属性指示)。using System;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Windows.Forms.VisualStyles;namespace ToolTipExample
    {
        // Form for the ToolTip example.
        public class ToolTipExampleForm : System.Windows.Forms.Form
        {
            private System.Windows.Forms.ToolTip toolTip1;
            private System.Windows.Forms.Button button1;
            private System.Windows.Forms.Button button2;
            private System.Windows.Forms.Button button3;        public ToolTipExampleForm()
            {
                // Create the ToolTip and set initial values.
                this.toolTip1 = new System.Windows.Forms.ToolTip();
                this.toolTip1.AutoPopDelay = 5000;
                this.toolTip1.InitialDelay = 500;
                this.toolTip1.OwnerDraw = true;
                this.toolTip1.ReshowDelay = 10;
                this.toolTip1.Draw += new DrawToolTipEventHandler(this.toolTip1_Draw);
                this.toolTip1.Popup += new PopupEventHandler(toolTip1_Popup);            // Create button1 and set initial values.
                this.button1 = new System.Windows.Forms.Button();
                this.button1.Location = new System.Drawing.Point(8, 8);
                this.button1.Text = "Button 1";
                this.toolTip1.SetToolTip(this.button1, "Button1 tip text");            // Create button2 and set initial values.
                this.button2 = new System.Windows.Forms.Button();
                this.button2.Location = new System.Drawing.Point(8, 32);
                this.button2.Text = "Button 2";
                this.toolTip1.SetToolTip(this.button2, "Button2 tip text");            // Create button3 and set initial values.
                this.button3 = new System.Windows.Forms.Button();
                this.button3.Location = new System.Drawing.Point(8, 56);
                this.button3.Text = "Button 3";
                this.toolTip1.SetToolTip(this.button3, "Button3 tip text");            // Set up the Form.
                this.Controls.AddRange(new Control[] {
                    this.button1, this.button2, this.button3
                });
                this.Text = "owner drawn ToolTip example";
            }        // Clean up any resources being used.        
            protected override void Dispose(bool disposing)
            {
                if (disposing)
                {
                    toolTip1.Dispose();
                }            base.Dispose(disposing);
            }        // The main entry point for the application.
            [STAThread]
            static void Main()
            {
                Application.Run(new ToolTipExampleForm());
            }        // Determines the correct size for the button2 ToolTip.
            private void toolTip1_Popup(object sender, PopupEventArgs e)
            {
                if (e.AssociatedControl == button2)
                {
                    using (Font f = new Font("Tahoma", 9))
                    {
                        e.ToolTipSize = TextRenderer.MeasureText(
                            toolTip1.GetToolTip(e.AssociatedControl), f);
                    }
                }
            }        // Handles drawing the ToolTip.
            private void toolTip1_Draw(System.Object sender, 
                System.Windows.Forms.DrawToolTipEventArgs e)
            {
                // Draw the ToolTip differently depending on which 
                // control this ToolTip is for.
                // Draw a custom 3D border if the ToolTip is for button1.
                if (e.AssociatedControl == button1)
                {
                    // Draw the standard background.
                    e.DrawBackground();                // Draw the custom border to appear 3-dimensional.
                    e.Graphics.DrawLines(SystemPens.ControlLightLight, new Point[] {
                        new Point (0, e.Bounds.Height - 1), 
                        new Point (0, 0), 
                        new Point (e.Bounds.Width - 1, 0)
                    });
                    e.Graphics.DrawLines(SystemPens.ControlDarkDark, new Point[] {
                        new Point (0, e.Bounds.Height - 1), 
                        new Point (e.Bounds.Width - 1, e.Bounds.Height - 1), 
                        new Point (e.Bounds.Width - 1, 0)
                    });                // Specify custom text formatting flags.
                    TextFormatFlags sf = TextFormatFlags.VerticalCenter |
                                         TextFormatFlags.HorizontalCenter |
                                         TextFormatFlags.NoFullWidthCharacterBreak;                // Draw the standard text with customized formatting options.
                    e.DrawText(sf);
                }
                // Draw a custom background and text if the ToolTip is for button2.
                else if (e.AssociatedControl == button2)
                {
                    // Draw the custom background.
                    e.Graphics.FillRectangle(SystemBrushes.ActiveCaption, e.Bounds);                // Draw the standard border.
                    e.DrawBorder();                // Draw the custom text.
                    // The using block will dispose the StringFormat automatically.
                    using (StringFormat sf = new StringFormat())
                    {
                        sf.Alignment = StringAlignment.Center;
                        sf.LineAlignment = StringAlignment.Center;
                        sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None;
                        sf.FormatFlags = StringFormatFlags.NoWrap;
                        using (Font f = new Font("Tahoma", 9))
                        {
                            e.Graphics.DrawString(e.ToolTipText, f, 
                                SystemBrushes.ActiveCaptionText, e.Bounds, sf);
                        }
                    }
                }
                // Draw the ToolTip using default values if the ToolTip is for button3.
                else if (e.AssociatedControl == button3)
                {
                    e.DrawBackground();
                    e.DrawBorder();
                    e.DrawText();
                }
            }
        }
    }
      

  7.   

    to GhostAdai( 幽灵阿呆)
    貌似没有onPaint事件
      

  8.   

    你敲完override,空格就出来你要重写的事件了。
      

  9.   

    是的呀,敲也不出现,但是用popup和draw事件就OK了
      

  10.   

    刚才试了一下,还真没有,查了一下MSDN,发现ToolTip是从Component直接继承的,而不是Control,难怪没有了,那就只能用7楼的方法了。