<tfoot id='3RNIP'></tfoot>
<legend id='3RNIP'><style id='3RNIP'><dir id='3RNIP'><q id='3RNIP'></q></dir></style></legend>
  • <small id='3RNIP'></small><noframes id='3RNIP'>

        <bdo id='3RNIP'></bdo><ul id='3RNIP'></ul>
    1. <i id='3RNIP'><tr id='3RNIP'><dt id='3RNIP'><q id='3RNIP'><span id='3RNIP'><b id='3RNIP'><form id='3RNIP'><ins id='3RNIP'></ins><ul id='3RNIP'></ul><sub id='3RNIP'></sub></form><legend id='3RNIP'></legend><bdo id='3RNIP'><pre id='3RNIP'><center id='3RNIP'></center></pre></bdo></b><th id='3RNIP'></th></span></q></dt></tr></i><div id='3RNIP'><tfoot id='3RNIP'></tfoot><dl id='3RNIP'><fieldset id='3RNIP'></fieldset></dl></div>

      1. 如何在 WinForms 中将字典绑定到 ListBox

        时间:2023-10-07
              <tbody id='Y7w2O'></tbody>

              <small id='Y7w2O'></small><noframes id='Y7w2O'>

                <legend id='Y7w2O'><style id='Y7w2O'><dir id='Y7w2O'><q id='Y7w2O'></q></dir></style></legend>
                  <bdo id='Y7w2O'></bdo><ul id='Y7w2O'></ul>
                • <tfoot id='Y7w2O'></tfoot>

                  <i id='Y7w2O'><tr id='Y7w2O'><dt id='Y7w2O'><q id='Y7w2O'><span id='Y7w2O'><b id='Y7w2O'><form id='Y7w2O'><ins id='Y7w2O'></ins><ul id='Y7w2O'></ul><sub id='Y7w2O'></sub></form><legend id='Y7w2O'></legend><bdo id='Y7w2O'><pre id='Y7w2O'><center id='Y7w2O'></center></pre></bdo></b><th id='Y7w2O'></th></span></q></dt></tr></i><div id='Y7w2O'><tfoot id='Y7w2O'></tfoot><dl id='Y7w2O'><fieldset id='Y7w2O'></fieldset></dl></div>

                  本文介绍了如何在 WinForms 中将字典绑定到 ListBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  可以将 Dictionary 绑定到 Listbox,在 Listbox 和成员属性之间保持同步吗?

                  It is possible to bind a Dictionary to a Listbox, keeping in sync between the Listbox and the member property?

                  推荐答案

                  var choices = new Dictionary<string, string>(); 
                  choices["A"] = "Arthur"; 
                  choices["F"] = "Ford"; 
                  choices["T"] = "Trillian"; 
                  choices["Z"] = "Zaphod"; 
                  listBox1.DataSource = new BindingSource(choices, null); 
                  listBox1.DisplayMember = "Value"; 
                  listBox1.ValueMember = "Key"; 
                  

                  (无耻地从我自己的博客中提取:Bind一个 ComboBox 到一个通用字典.)

                  (Shamelessly lifted from my own blog: Bind a ComboBox to a generic Dictionary.)

                  这意味着您可以使用 SelectedValue 来获取列表框中所选项目的相应字典键.

                  This means you can use SelectedValue to get hold of the corresponding dictionary key for the selected item in the ListBox.

                  这篇关于如何在 WinForms 中将字典绑定到 ListBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将字符串拆分为多个值? 下一篇:C# 我可以在列表框中显示图像吗?

                  相关文章

                  <small id='7ueWe'></small><noframes id='7ueWe'>

                    <i id='7ueWe'><tr id='7ueWe'><dt id='7ueWe'><q id='7ueWe'><span id='7ueWe'><b id='7ueWe'><form id='7ueWe'><ins id='7ueWe'></ins><ul id='7ueWe'></ul><sub id='7ueWe'></sub></form><legend id='7ueWe'></legend><bdo id='7ueWe'><pre id='7ueWe'><center id='7ueWe'></center></pre></bdo></b><th id='7ueWe'></th></span></q></dt></tr></i><div id='7ueWe'><tfoot id='7ueWe'></tfoot><dl id='7ueWe'><fieldset id='7ueWe'></fieldset></dl></div>
                      • <bdo id='7ueWe'></bdo><ul id='7ueWe'></ul>

                      <legend id='7ueWe'><style id='7ueWe'><dir id='7ueWe'><q id='7ueWe'></q></dir></style></legend>

                    1. <tfoot id='7ueWe'></tfoot>