简体   繁体   中英

WindowsForms TopMost versus ComboBox

I have a WindowsForms application in which I open a Form as a Dialog (Form2.ShowDialog) and in this Form I have a Timer that sets the TopMost property of the Form to true. But I also have a ComboBox in this Form and when I click on the ComboBox to select an Item, the list opens and closes immediately as the Timer sets the TopMost property back to true.

If you ask me This is wrong way and should be replace your "load data function" from timer to form_load event. so if you want current way you should disable timer in ComboBox Enter Event and enable timer in ComboBox Leave Event.

    private void comboBox1_Enter(object sender, EventArgs e)
    {
        timer1.Enabled = false;
    }

    private void comboBox1_Leave(object sender, EventArgs e)
    {
        timer1.Enabled = true;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM