C# String 折行(換行)、連接符號
C# String 折行(換行)、連接符號
資料來源: https://dotblogs.com.tw/yypass2002/2013/08/13/114391
1. 使用 + 符號 – 連接符號
string strSQL= "SELECT * FROM HumanResources.Employee AS e" + " INNER JOIN Person.Contact AS c" + " ON e.ContactID = c.ContactID" + " ORDER BY c.LastName";
2.使用 @ 符號 – 連接符號
string strSQL= @"SELECT * FROM HumanResources.Employee AS e INNER JOIN Person.Contact AS c ON e.ContactID = c.ContactID ORDER BY c.LastName";
3.Label 控制項中要換行”<br>”
lblUser.Text = "編號:" + lblSno.Text + "<br>" + "姓名:" + txtName + "<br>" + "電話:" + txtTel ;
4.TextBox控制項中要換行”\r\n”
textBox1.Text = "編號:" + id + "\r\n" + "姓名" + Name +"\r\n" + "電話" + Tel;
注意其 TextMode需設為MultiLine 才會有效果;預設為SingleLine
或於程式碼中先加入
txtBox1.TextMode =TextBoxMode .MultiLine ;