Why ComboBox hides cursor when DroppedDown is set?

Posted by Ivan Danilov on Stack Overflow See other posts from Stack Overflow or by Ivan Danilov
Published on 2009-07-07T15:37:03Z Indexed on 2010/04/18 11:43 UTC
Read the original article Hit count: 471

Filed under:
|
|

Let's create WinForms Application (I have Visual Studio 2008 running on Windows Vista, but it seems that described situation takes place almost everywhere from Win98 to Vista, on native or managed code).

Write such code:

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;
        }
    }
}

Then, run app. Place mouse cursor on the form and don't touch mouse anymore. Start to type something in TextBox - cursor will hide because of it. When you press Enter key - event throws and ComboBox will be dropped down. But now cursor won't appear even if you move it! And appears only when you click somewhere.

There I've found discussion of this problem. But there's no good solution...

Any thoughts? :)

© Stack Overflow or respective owner

Related posts about winforms

Related posts about c#