首页 新闻 会员 周边

自定义控件使用后,页面上的所有控件不能使用

0
悬赏园豆:50 [待解决问题]

放一个自定义控件在页面上,当打开那个页面后,鼠标滑过后,该页面的所有控件不能用。要ALT+TAB切换一下。但是切换过后,也只能点一下其他的控件一次。

我找到自己写的鼠标移过的事件。

protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            UpdateLeave();
        }

        public void UpdateLeave()
        {
            if (_keeppress == false | (_keeppress == true & _ispressed == false))
            {
                _colorStroke = ColorBaseStroke;
                _showbase = _tempshowbase;
                i_mode = 0;
                mouse = false;
                if (i_factor == 0)
                {
                    R0 = _baseColor.R; G0 = _baseColor.G; B0 = _baseColor.B;
                    this.Refresh();
                }
                else
                {
                    timer1.Stop();
                    timer1.Start();//

将这个移除后,页面的控件能用,但是控件的(鼠标移出后的样式又没了)


                }
            }
        }

急啊!求思路和解决方式

 

问题补充: //还有一个移进的事件 protected override void OnMouseEnter(EventArgs e) { base.OnMouseEnter(e); _colorStroke = ColorOnStroke; _tempshowbase = _showbase; _showbase = e_showbase.Yes; i_mode = 1; xmouse = PointToClient(Cursor.Position).X; mouse = true; A0 = 200; if (i_factor == 0) { R0 = _onColor.R; G0 = _onColor.G; B0 = _onColor.B; } timer1.Start(); }
yxjyxj的主页 yxjyxj | 初学一级 | 园豆:170
提问于:2010-12-09 15:46
< >
分享
所有回答(3)
0

这个控件的功能是什么?

顾晓北 | 园豆:10844 (专家六级) | 2010-12-09 16:06
就是一个关闭的按钮!只不过有个鼠标移进移出的样式。
支持(0) 反对(0) yxjyxj | 园豆:170 (初学一级) | 2010-12-09 16:09
那你在用这个控件的时候代码是什么?
支持(0) 反对(0) 顾晓北 | 园豆:10844 (专家六级) | 2010-12-09 16:20
没有代码呀!控件直接就拖过来用了,那个控件的后台代码是public CloseButton() { InitializeComponent(); this.Image = Properties.Resources.Close; this.Size =new Size(80,64); } protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); } public override string Text { get { return base.Text; } set { base.Text = "退出(ESC)"; } }
支持(0) 反对(0) yxjyxj | 园豆:170 (初学一级) | 2010-12-09 16:36
还有个 using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Drawing.Imaging; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace ControlsLib.Buttons { [DefaultProperty("ButtonImage")] public class OperateBaseButton : ShortCutButton { public enum ImageType { 无, 新增, 修改, 保存, 删除, 查询, 打印, 文件, 文件夹, 打开的文件夹, 帮助, 设置, 定位, 图表, 刷新, 关闭, 导入, 导出, 定位II, 全选, 复制 } #region About Constructor public OperateBaseButton() { this.SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.DoubleBuffer, true); this.SetStyle(ControlStyles.Opaque, false); //默认属性 InitStyle(); timer1.Interval = 5; timer1.Tick += new EventHandler(timer1_Tick); } private ImageType buttonImage = ImageType.无; [Category("Apperance"), Description("用于设置按钮的图标")] public ImageType ButtonImage { get { return buttonImage; } set { buttonImage = value; switch (value) { case ImageType.新增: this.Image = Properties.Resources.Add; break; case ImageType.保存: this.Image = Properties.Resources.Save; break; case ImageType.修改: this.Image = Properties.Resources.Edit; break; case ImageType.删除: this.Image = Properties.Resources.Add;
支持(0) 反对(0) yxjyxj | 园豆:170 (初学一级) | 2010-12-09 16:37
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Drawing.Imaging; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace ControlsLib.Buttons { [DefaultProperty("ButtonImage")] public class OperateBaseButton : ShortCutButton { public enum ImageType { 无, 新增, 修改, 保存, 删除, 查询, 打印, 文件, 文件夹, 打开的文件夹, 帮助, 设置, 定位, 图表, 刷新, 关闭, 导入, 导出, 定位II, 全选, 复制 } #region About Constructor public OperateBaseButton() { this.SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.DoubleBuffer, true); this.SetStyle(ControlStyles.Opaque, false); //默认属性 InitStyle(); timer1.Interval = 5; timer1.Tick += new EventHandler(timer1_Tick); } private ImageType buttonImage = ImageType.无; [Category("Apperance"), Description("用于设置按钮的图标")] public ImageType ButtonImage { get { return buttonImage; } set { buttonImage = value; switch (value) { case ImageType.新增: this.Image = Properties.Resources.Add; break; case ImageType.保存: this.Image = Properties.Resources.Save; break; case ImageType.修改: this.Image = Properties.Resources.Edit; break; case ImageType.删除: this.Image = Properties.Resources.Add;
支持(0) 反对(0) yxjyxj | 园豆:170 (初学一级) | 2010-12-09 16:39
我晕,这格式怎么成这样了
支持(0) 反对(0) yxjyxj | 园豆:170 (初学一级) | 2010-12-09 16:40
你说的页面其他控件不能用?是怎么个不能用法?能截图上传上来不能?
支持(0) 反对(0) 顾晓北 | 园豆:10844 (专家六级) | 2010-12-09 16:42
代码太长了,你加断点调试。。。
支持(0) 反对(0) 顾晓北 | 园豆:10844 (专家六级) | 2010-12-09 16:43
整个页面的控件点击没反应。
支持(0) 反对(0) yxjyxj | 园豆:170 (初学一级) | 2010-12-09 17:25
先看看你这个控件继承于哪个类。
支持(0) 反对(0) 顾晓北 | 园豆:10844 (专家六级) | 2010-12-09 17:39
谢谢你的回答。
支持(0) 反对(0) yxjyxj | 园豆:170 (初学一级) | 2010-12-09 17:52
0

估计是焦点问题,你焦点锁定在控件上,所以其他控件只能alt+tab才能用。用完焦点又锁定了。你在仔细看看你的自定义控件的代码。

茂茂 | 园豆:2892 (老鸟四级) | 2010-12-09 23:42
谢谢回答!但我找了一下,好像也没找到啊.
支持(0) 反对(0) yxjyxj | 园豆:170 (初学一级) | 2010-12-10 22:16
0

用firebug调试一下。

Astar | 园豆:40805 (高人七级) | 2010-12-11 06:46
谢谢提醒!
支持(0) 反对(0) yxjyxj | 园豆:170 (初学一级) | 2010-12-11 22:47
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册