如何在label中输入回车换行?/r/n没用

tianyaboy 2004-03-31 08:22:16


??
...全文
2637 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhhahuatian 2004-03-31
  • 打赏
  • 举报
回复
首先你要明白转意字符,你可以输入“\\n\\r”,由于lable 中输入的是字符串,在字符串中好像和平时不同
liuyu202 2004-03-31
  • 打赏
  • 举报
回复
实在不行就多用几个Label了!
acui9937 2004-03-31
  • 打赏
  • 举报
回复
楼住的问题应该是这样的:
你需要进行转换
content = content.Replace("\n","<br>");
content = content.Replace("\r","<br>");
return content;
feelingbox 2004-03-31
  • 打赏
  • 举报
回复
<br>可不可以啊^_^
HNU 2004-03-31
  • 打赏
  • 举报
回复


很简单

在Text属性中多输入空格,文字碰到边框就会自动换行。

和VC不一样

:)
tianyaboy 2004-03-31
  • 打赏
  • 举报
回复


真奇怪啊,代码里修改添加回车换行可以,对应的Text属性里居然对应添加了看不件的空格



我问的就是要在属性Text中设置,难道真的不可以吗?
marvelstack 2004-03-31
  • 打赏
  • 举报
回复
下面使用,不过楼主要把Label拉得足够大。

public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.ComponentModel.Container components = null;
public MainForm()
{
InitializeComponent();
this.label1.Text = @"第一行
第一行
第二行
第三行
第四行";

}

#region
/// <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.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(152, 56);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(168, 96);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(496, 325);
this.Controls.Add(this.label1);
this.Name = "MainForm";
this.Text = "MainForm";
this.ResumeLayout(false);

}
#endregion
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}


}
KentYu 2004-03-31
  • 打赏
  • 举报
回复
楼主搞错了吧?:)
tianyaboy 2004-03-31
  • 打赏
  • 举报
回复


label1.Text = ??;是回车换行
tianyaboy 2004-03-31
  • 打赏
  • 举报
回复


\r\n

输入后显示“\r\n”!
孟子E章 2004-03-31
  • 打赏
  • 举报
回复
\r\n

or
System.Environment.NewLine;

111,119

社区成员

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

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

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