<bdo id='ytkFU'></bdo><ul id='ytkFU'></ul>

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

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

    <tfoot id='ytkFU'></tfoot>

      1. 将列表框的选定值显示为标签 - 多个值

        Display selectedvalues of listbox as label - multiple values(将列表框的选定值显示为标签 - 多个值)
          <tbody id='zqBPg'></tbody>
          • <bdo id='zqBPg'></bdo><ul id='zqBPg'></ul>
          • <i id='zqBPg'><tr id='zqBPg'><dt id='zqBPg'><q id='zqBPg'><span id='zqBPg'><b id='zqBPg'><form id='zqBPg'><ins id='zqBPg'></ins><ul id='zqBPg'></ul><sub id='zqBPg'></sub></form><legend id='zqBPg'></legend><bdo id='zqBPg'><pre id='zqBPg'><center id='zqBPg'></center></pre></bdo></b><th id='zqBPg'></th></span></q></dt></tr></i><div id='zqBPg'><tfoot id='zqBPg'></tfoot><dl id='zqBPg'><fieldset id='zqBPg'></fieldset></dl></div>

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

                • <legend id='zqBPg'><style id='zqBPg'><dir id='zqBPg'><q id='zqBPg'></q></dir></style></legend>

                  <tfoot id='zqBPg'></tfoot>
                • 本文介绍了将列表框的选定值显示为标签 - 多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个名为 lstPTLNameDHOD 的列表框,它有多个使用 Ctrl 选择的 PTL 名称.我想以标签或某种方式显示选定的名称,以便提交表单的人可以看到他们究竟是为谁提交的.

                  I have got a list box called lstPTLNameDHOD which has multiple PTL names which gets selected using Ctrl. I want to display the selected names in a label or some way that the person submitted the form can see who exactly they are submitting it for.

                  我的问题是我只能在标签上显示一个名称.

                  My problem is I can only get one name to display on the label.

                  // Items collection
                  foreach (ListItem item in lstPTLNameDHOD.Items)
                  {
                     if (item.Selected)
                     {
                         lbl1stPTL.Text = item.Value.ToString();
                  
                     }
                  }
                  

                  在更改下拉列表的原因后回发时调用它.

                  This is being called on post back on the reason dropdown being changed.

                  推荐答案

                  您只会显示一个名称,因为您当前的代码将始终显示最后选择的项目的名称.

                  You are only getting one name to display because your current code would always display name of the last item that is selected.

                  我手边没有视觉工作室,但你可以试试这个:

                  I don't have a visual studio handy but you could try this:

                  StringBuilder sbText = new StringBuilder();
                  // Items collection
                  foreach (ListItem item in lstPTLNameDHOD.Items)
                  {
                     if (item.Selected)
                     {
                         lbl1stPTL.Text = sbText.Append(item.Value.ToString()).ToString();
                     }
                  }
                  

                  您可能可以通过在两个项目名称之间添加一个空格或逗号来改进这一点,但我希望您明白这个想法并且它会有所帮助!

                  You can probably refine this by adding a space or a comma between two item names but I hope you get the idea and it helps!

                  再次,很抱歉没有 VS!

                  Again, sorry for not having VS handy!

                  这篇关于将列表框的选定值显示为标签 - 多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 列表框上的取消选择)
                  • <legend id='KMDmu'><style id='KMDmu'><dir id='KMDmu'><q id='KMDmu'></q></dir></style></legend>

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

                        <tbody id='KMDmu'></tbody>

                        <bdo id='KMDmu'></bdo><ul id='KMDmu'></ul>

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

                            <tfoot id='KMDmu'></tfoot>