加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

C# – 当DroppedDown设置时,为什么ComboBox隐藏光标?

发布时间:2020-12-15 06:41:06 所属栏目:百科 来源:网络整理
导读:我们创建WinForms应用程序(我有Visual Studio 2008在 Windows Vista上运行,但似乎描述的情况几乎从Win98到Vista,本机或托管代码). 写这样的代码: using System;using System.Drawing;using System.Windows.Forms;namespace WindowsFormsApplication1{ publi
我们创建WinForms应用程序(我有Visual Studio 2008在 Windows Vista上运行,但似乎描述的情况几乎从Win98到Vista,本机或托管代码).

写这样的代码:

using System;
using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public class Form1 : Form
    {
        private readonly Button button1 = new Button();
        private readonly ComboBox comboBox1 = new ComboBox();
        private readonly TextBox textBox1 = new TextBox();

        public Form1() {
            SuspendLayout();
            textBox1.Location = new Point(21,51);
            button1.Location = new Point(146,49);
            button1.Text = "button1";
            button1.Click += button1_Click;
            comboBox1.Items.AddRange(new[] {"1","2","3","4","5","6"});
            comboBox1.Location = new Point(21,93);
            AcceptButton = button1;
            Controls.AddRange(new Control[] {textBox1,comboBox1,button1});
            Text = "Form1";
            ResumeLayout(false);
            PerformLayout();
        }

        private void button1_Click(object sender,EventArgs e) {
            comboBox1.DroppedDown = true;
        }
    }
}

然后,运行应用程序.将鼠标光标放在表单上,??不要再触摸鼠标.开始在TextBox中键入一些东西 – 光标会隐藏起来.当您按Enter键 – 事件抛出和ComboBox将被删除.但现在光标不会出现,即使你移动它!只有当您点击某处时才会出现.

There我发现这个问题的讨论.但是没有什么好的解决方案

有什么想法吗?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读