2016-10-29 8 views
1

안녕하세요, 액세스 데이터베이스에서 내 텍스트 상자로 데이터를 검색 할 때 여러 줄 텍스트 상자에 데이터가 하나씩 표시됩니다. 예를 들어 모든 줄이 그 줄에 있어야합니다. 예를 들어 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(); 

답변

0

새 줄을 만들려면 'new line character' "\ n"문자열을 사용하십시오. 이처럼 :

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

덕분에 형제를이 시도하지만 같은 숫자는 07704425588 0,770,258 비슷하지만 077044255880770258처럼 보여 –

1

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; 
}