我从数据库取出一个字符串内容是
string str="我的中国心\r\n我的呵呵"
现在我想把str附给一个label控件.
但是\r\n在label里并没有换行,只是两个空格,我想要换行怎么办.
string str="我的中国心\r\n我的呵呵"
现在我想把str附给一个label控件.
但是\r\n在label里并没有换行,只是两个空格,我想要换行怎么办.
调试欢乐多
如果"1\r\n ssssssssssssssssss\r\n bb\r\n"像这们的就没法控制长度呀.
定义widthstring str = "我的中国心我的呵呵";
Label1.Text=str;
int RowNum = (int) txtBoxSp.Width/12; //每行显示的字数(计算出来的)
int RowHeight = 12; //每行的高度
int ColNum = (LblNum - (LblNum / RowNum) * RowNum) == 0 ? (LblNum / RowNum) : (LblNum / RowNum) + 1; //列数
if(ColNum == 1)
{
this.Height = 278; //禁止窗体显示textBox;
this.AutoSize = false;
}
else
{
txtBoxSp.AutoSize = true; //设置AutoSize
txtBoxSp.Height = RowHeight * ColNum; //设置显示高度
this.Height = 303 + txtBoxSp.Height + 6; //实现窗体高度的自动调整
}
string str = "1\r\n ssssssssssssssssss\r\n bb\r\n";
Label1.Text=str.Replace("\r\n","<br>");
不好用是个什么概念?
像这个"1\r\n ssssssssssssssssss\r\n bb\r\n"显示的结果是
1
ssssssssssssssssss
bb
string str = "我的中国心\r\n我的呵呵";
str=str.Replace("\r\n","<br />");
Label1.Text=str;