中国设计联盟
联网
平面设计 画册 VI欣赏 包装 CG-插画 搜索 个人网页 Alexa排名 CSS 建站资源 下载专区 JS特效 品牌服装 服装院校 专题欣赏 SEO 图标欣赏 专题
域名注册 虚拟主机 广州网站设计 域名注册 广州网站建设 上海网站建设 虚拟主机 广州网页设计  虚拟主机 域名注册 acg王国 ACG玩家
求创科技
上海网站建设
中国福网
招聘求职
中国互联
中国设计秀
中资源
当前位置:网络学院首页 >> 编程开发 >> .net >> XPBalloonTip 控件的使用方法

XPBalloonTip 控件的使用方法 (1)

来源:中国设计秀    作者:    点击:31     加入收藏    发表评论
0
顶一下

   试图把 XP Common Controls 用到实际项目中时,发现气泡提示控件并不象想象中的那样工作。对于textbox来说还是可以正常工作的,但对于象combox box 、lable等控件就好象罢工了一样,为了达到能和 textbox 同样的气泡提示效果,自己补充了一点代码。
 
namespace HBus.Common
...{
    /**//// <summary>
    /// 气泡提示控件
    /// </summary>
    public class xpBalloonTipExtender:Steepvalley.Windows.Forms.APIEnhanced.XPBalloonTip,IDisposable
    ...{
        private System.Windows.Forms.TextBox txt = new System.Windows.Forms.TextBox();
        private System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
        private System.Windows.Forms.Control target = null;

        public xpBalloonTipExtender(System.Windows.Forms.Control parent)
            : base()
        ...{
            parent.Controls.Add(txt);
            txt.Visible = false;

            timer.Enabled = false;
            timer.Tick += new EventHandler(timer_Tick);
        }

        void timer_Tick(object sender, EventArgs e)
        ...{
            txt.Visible = false;
            timer.Enabled = false;
            if (target != null)
            ...{
                target.Focus();
            }
   target = null;
        }     

        private void Attach(System.Windows.Forms.Control ctrl)
        ...{
            txt.Width = 1;
            txt.BorderStyle = System.Windows.Forms.BorderStyle.None;
            txt.BackColor = ctrl.BackColor;
            txt.Location =  ctrl.Location;
            txt.Height = ctrl.Height;
            txt.Visible = true;

            target = ctrl;
        }

        private void Attach(System.Windows.Forms.Control ctrl, int timeout)
        ...{
            Attach(ctrl);
            timer.Interval = 1000 * timeout;
            timer.Enabled = true;
        }

        public new void Hide(System.Windows.Forms.Control ctrl)
        ...{
            if(this.target == ctrl)
            ...{
                base.Hide(txt);
                txt.Visible = false;
                if (target != null)
                ...{      target.Focus();
                }
                target = null;
            }            
        }

[1] [2] [3]
2007-08-27 15:51:00    出处:
网站地图 | 关于我们 | 联系我们 | 网站建设 | 广告服务 | 版权声明 | 免责声明 | 网站公告 | 友情链接 | 留言 | 旧版入口