请问在C#中的textbox中换行怎么写,为什么textBox.text = "aaaaaaaaaaaa"+"\n" 不行
请问在C#中的textbox中换行怎么写
textBox.text = "aaaaaaaaaaaa"+"\n" 不行
谢谢了
问题点数:20、回复次数:11Top
1 楼brightheroes(在地狱中仰望天堂)回复于 2004-11-02 12:51:35 得分 0
MutiLine设置为true
this.textBox1.Text = "aa" + "\r\n" + " b";Top
2 楼csdnweb(webcsdn)回复于 2004-11-02 12:54:55 得分 0
我也设了MutiLine设置为true
this.textBox1.Text = "aa" + "\r\n" + " b";
可还是不行,
我的是winformTop
3 楼brightheroes(在地狱中仰望天堂)回复于 2004-11-02 12:55:15 得分 10
WebForm
设置TextMode为MutiLineTop
4 楼csdnweb(webcsdn)回复于 2004-11-02 12:57:26 得分 0
可是我现在做的是 winform 啊
请你帮我想想
谢谢了
Top
5 楼brightheroes(在地狱中仰望天堂)回复于 2004-11-02 13:04:54 得分 0
try
this.textBox2.Multiline = true;
this.textBox2.Height = 40;
this.textBox2.Text = "aa" + "\r\n" + " b";Top
6 楼trnbo(【没有蛀牙】)回复于 2004-11-02 13:09:20 得分 10
this.textBox1.Text = "a" + "\r\n" + "b";测试可以啊。
楼主你把textbox的高度设宽一点,呵呵Top
7 楼trnbo(【没有蛀牙】)回复于 2004-11-02 13:10:30 得分 0
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace test
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(96, 88);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 56);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(112, 184);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
this.textBox1.Text = "a" + "\r\n" + "b";
}
}
}
上边的代码保证可以运行,呵呵Top
8 楼dazhu2(【倚天不出,谁与争锋】)回复于 2004-11-02 13:17:39 得分 0
this.textBox1.Text="你好,\r\n hello";这样可以的,\r\n 顺序不可倒Top
9 楼dragonforfly(飘零)回复于 2004-11-02 13:20:38 得分 0
设置属性MutiLine了吗Top
10 楼csdnweb(webcsdn)回复于 2004-11-02 13:22:38 得分 0
谢谢各位刚才看错了
Top
11 楼flareboy(Programmer Me=New Programmer("C#"))回复于 2004-11-02 15:01:02 得分 0
Winform 中
设MultiLine为True
还要把Height设的足够大
这样才能容纳两行
然后:this.textBox1.Text="Line 1 " + "\r\n" + "Line 2";Top




