Help us understand the problem. What is going on with this article?

ComboBoxとListBoxを縦に並べたときのListBoxのちらつきを抑止する

More than 5 years have passed since last update.

複数の名前付きのリストから一つを選択したときにその内容を表示するために、ComboBoxとListBoxを縦に並べることがあります。このときListBoxに含まれているアイテムを選択した後に、ComboBoxをドロップダウンすると、アイテムを挿入し直したかのようなちらつきがListBoxに起こります。二回目以降のドロップダウンではこれは起こりません。

ff59bf4e6c89b1865ef150ea877e9953.gif

この問題を解決する方法は、stacoverflowのvb.net listbox flicker when selecting comboboxの回答にあります。以下のようにListBoxからフォーカスが失われるときにUpdateを呼んでおくだけです。ComboBoxにフォーカスが移る前に一度ListBoxを描画しておくと、ComboBoxのドロップダウンでちらつきが起こるのを防げるようです。よくこんな方法を思い付いたものです。

    private void listBox1_Leave(object sender, System.EventArgs e)
    {
        listBox1.Update();
    }
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away