在线等,C# winform怎么把一个数组foreach便利后放到一个texbox里面

hankai125 2010-11-22 02:31:00
在texbox里面然后换行显示出来
...全文
157 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
hankai125 2010-11-22
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 ckhker 的回复:]
form2里声明一个全局变量
public static string text;

然后设置form2中的texbox.text=text

form1里用foreach 方法遍历出内容 =form2.text
[/Quote]

在from1里面用foreach便利后 传到from2里面 弹出来的窗体则是一个一个的弹出来 有几个数据弹出几个

怎么办啊
寒叶gg 2010-11-22
  • 打赏
  • 举报
回复
form2里声明一个全局变量
public static string text;

然后设置form2中的texbox.text=text

form1里用foreach 方法遍历出内容 =form2.text
  • 打赏
  • 举报
回复
很简单。。。你只需要把数组传过去。。。然后遍历就OK了

string[] str = { "aa", "bb", "cc", "dd" };
foreach (string s in str)
{
this.Textbox.Text += s + "\n";
}
hankai125 2010-11-22
  • 打赏
  • 举报
回复
我想弹出另一个窗口 然后在这个 窗口中放一个textbox ,然后 把数据放到这个textbox里面
piao2004 2010-11-22
  • 打赏
  • 举报
回复
string ss="";
foreach (string s in StringArray)
{
ss+=s;
}
textbox1.text=ss;
jshi123 2010-11-22
  • 打赏
  • 举报
回复
string[] arr = { "aa", "bb", "cc", "dd" };
textBox1.Multiline = true;
textBox1.Height = 200;
this.textBox1.Lines = arr;
xieganlin 2010-11-22
  • 打赏
  • 举报
回复
string[] arr = { "aa", "bb", "cc", "dd" };
foreach (string num in arr)
{
this.Textbox.Text += num.ToString() + "\t";
}
tyougyokuki 2010-11-22
  • 打赏
  • 举报
回复

private void Test()
{
int[] ary = new int[] { 1, 2, 3 };
string msg = string.Empty;
foreach (int num in ary)
{
msg += num.ToString() + "\r";
}
MessageBox.Show(msg);
}

使用TextBox显示的话,把Multiline属性设置为true.

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧