<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

        How to bind Dictionary to ListBox in WinForms(如何在 WinForms 中将字典绑定到 ListBox)
              <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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)

                  <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>
                          <tbody id='7ueWe'></tbody>

                            <bdo id='7ueWe'></bdo><ul id='7ueWe'></ul>

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

                          • <tfoot id='7ueWe'></tfoot>