CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  C#

请问在C#中的textbox中换行怎么写,为什么textBox.text = "aaaaaaaaaaaa"+"\n" 不行

楼主csdnweb(webcsdn)2004-11-02 12:49:10 在 .NET技术 / C# 提问

请问在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

相关问题

  • @@@@@ N C N E @@@@@
  • 【 魂 断 C S D N 】
  • what's meaning? n[c - '0']
  • C语言里“%n”是什么意思
  • c++中怎样实现n!谢谢。
  • 初学C++,请问n!是什么?
  • [C#] textBox 怎樣判斷輸入是Enter。
  • 70余日本C__A__T__C__N骗子济南诈骗民工
  • Dim DesignText As TextBox=CType(e.Item.Cells(9).Controls(0),TextBox)写成C#怎么写啊?
  • 怎末在C#的Textbox中敲回车使光标跳到下一个Textbox中?

关键词

  • c#
  • 代码
  • textbox
  • mutiline
  • 不行
  • button
  • disposing
  • multiline
  • drawing
  • 设计器

得分解答快速导航

  • 帖主:csdnweb
  • brightheroes
  • trnbo

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo