• <small id='iXC7G'></small><noframes id='iXC7G'>

    <legend id='iXC7G'><style id='iXC7G'><dir id='iXC7G'><q id='iXC7G'></q></dir></style></legend>

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

        <tfoot id='iXC7G'></tfoot>

        显示列表&lt;字符串&gt;在文本框中(Winforms)

        Display Listlt;Stringgt; in textBox (Winforms)(显示列表lt;字符串gt;在文本框中(Winforms))

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

            <legend id='d86YK'><style id='d86YK'><dir id='d86YK'><q id='d86YK'></q></dir></style></legend>

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

              <bdo id='d86YK'></bdo><ul id='d86YK'></ul>
                    <tbody id='d86YK'></tbody>

                1. <tfoot id='d86YK'></tfoot>
                  本文介绍了显示列表&lt;字符串&gt;在文本框中(Winforms)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  菜鸟问题...我正在尝试在文本框中显示一个列表...不幸的是,我的代码仅显示列表中的第一个元素...

                  Noob question... I'm trying to display a List in a textbox... unfortunately, my code only displays the first element in the list...

                      private void Form1_Load(object sender, EventArgs e)
                      {
                          List<String> vegetables = new List<String>();
                          vegetables.Add("tomato");
                          vegetables.Add("carrot");
                          vegetables.Add("celery");
                          vegetables.Add("potato");
                  
                          textBox1.Text = displayMembers(vegetables);
                      }
                  
                      public string displayMembers(List<String> vegetables)
                      {
                          foreach (String s in vegetables)
                          {
                              return s.ToString();
                          }
                          return null;
                      }
                  

                  如何让文本框显示所有成员?我的错在哪里?

                  How do I get the textBox to display all of the members? Where is my mistake?

                  推荐答案

                  一旦你 return s.ToString(),该方法的其余部分将停止运行.
                  一个方法不能返回多个东西.

                  Once you return s.ToString(), the rest of that method stops running.
                  A method cannot return multiple things.

                  你可能想写

                  someTextBox.Text = String.Join(Environment.NewLine, vegetables);
                  

                  这篇关于显示列表&lt;字符串&gt;在文本框中(Winforms)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How to keep the Text of a Read only TextBox after PostBack()?(PostBack()之后如何保留只读文本框的文本?)
                  Winforms Textbox - Using Ctrl-Backspace to Delete Whole Word(Winforms 文本框 - 使用 Ctrl-Backspace 删除整个单词)
                  C# - Add button click events using code(C# - 使用代码添加按钮单击事件)
                  Multi-color TextBox C#(多色文本框 C#)
                  How can i set the caret position to a specific index in passwordbox in WPF(如何将插入符号位置设置为 WPF 密码框中的特定索引)
                  C# Numeric Only TextBox Control(C# 纯数字文本框控件)
                    <tbody id='5RZgS'></tbody>

                  1. <small id='5RZgS'></small><noframes id='5RZgS'>

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

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