Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能であれば、C# で ComboBox (WinForms) で選択した項目を中央の要素として表示する方法があるかどうか疑問に思っていました。これを可能にするプロパティまたはメソッドをすでに探しましたが、何も見つかりませんでした。私は開発中のアプリケーションでいくつかを使用していますが、この機能によりアプリの使いやすさが大幅に向上します。
どんな助けでも大歓迎です。
編集:「中間要素」とは、コンボボックスがドロップダウンされたときに表示されるものを意味します。このようなもの:
これがあなたの言いたいことだと思います。
OnFormLoad イベント: (または関数を実装する任意のボタン)
int count = comboBox.Items.Count; comboBox.SelectedIndex = count/2; //no need of if else statements
(また)
comboBox.SelectedIndex = comboBox.Items.Count/2;