Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在多行文本框中逐行显示文本_C#_C# 4.0_C# 3.0_Facebook C# Sdk_C# 2.0 - Fatal编程技术网

C# 在多行文本框中逐行显示文本

C# 在多行文本框中逐行显示文本,c#,c#-4.0,c#-3.0,facebook-c#-sdk,c#-2.0,C#,C# 4.0,C# 3.0,Facebook C# Sdk,C# 2.0,大家好,当我从access数据库检索数据到我的文本框多行文本框时,数据在一行旁边显示我希望任何一行都在它的行中例如,我的access字段中有5行,但在我的文本框中显示同一行中的所有数据我应该做些什么 OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\\db\\it.accdb"); con.Open()

大家好,当我从access数据库检索数据到我的文本框多行文本框时,数据在一行旁边显示我希望任何一行都在它的行中例如,我的access字段中有5行,但在我的文本框中显示同一行中的所有数据我应该做些什么

OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\\db\\it.accdb");

con.Open();

OleDbCommand cmd = new OleDbCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from data where [ID] like(" + textBox9.Text + ")";
cmd.Connection = con;

var reader = cmd.ExecuteReader();
while (reader.Read())
{
    textBox1.Text = reader["Name"].ToString();
    textBox20.Text = reader["Description"].ToString();

    // ----------------------------------------------
    // These doesn't work with me :
    // ----------------------------------------------
    //textBox2.Text = Environment.NewLine;
    //textBox28.Text = textBox28.Text + Environment.NewLine;
    //textBox2.Text = textBox28.Text + Environment.NewLine;

}

con.Close();

使用字符串“新行字符”'.\n“创建新行。像这样:

textBox1.Text = reader["Name"].ToString() + "\n";
textBox20.Text = reader["Description"].ToString() + "\n";
试试这个

textBox1.Multiline = true;
textBox1.ScrollBars = ScrollBars.Vertical;//Other settings is Horizontal and Both
textBox1.AcceptsReturn = true;
textBox1.WordWrap = true;

textBox20.Multiline = true;
textBox20.ScrollBars = ScrollBars.Vertical;//Other settings is Horizontal and Both
textBox20.AcceptsReturn = true;
textBox20.WordWrap = true;

while (reader.Read())
{
    textBox1.Text += reader["Name"].ToString() + Environment.NewLine;
    textBox20.Text += reader["Description"].ToString() + Environment.NewLine;
}

谢谢兄弟,但它的号码是一样的07704425588 0770258,但它显示像077044255880770258