[英]How can I display multi line text from access database into DataGridView in C#
this is my Access database这是我的 Access 数据库
as you see in Blood Group Row I have a multiline in testUnit Column A+, A-, O+, O-, etc...正如您在 Blood Group Row 中看到的,我在 testUnit 列 A+、A-、O+、O- 等中有一条多行...
my problem is below我的问题在下面
Why dataGridView display these lines text between divs?为什么 dataGridView 在 div 之间显示这些行文本? I set Wrap-text true
我将Wrap-text true
but it doesn't solve my problem.. the expected output in datagridview但这并不能解决我的问题.. datagridview 中的预期 output
( without div tag ) (没有 div 标签)
DATATYPE of field (field used to store many lines in) SHOULD BE Long Text
and make the TextFormat plain text as show below字段的数据类型(用于存储多行的字段)应该是Long Text
并使 TextFormat 纯文本如下所示
When rebinding your columns, use Eval("testUnit") instead of bind.重新绑定列时,请使用 Eval("testUnit") 而不是绑定。 I remember this for you, i hope this is useful for you...我为你记住了这个,我希望这对你有用......
Do this in your DataBase在您的数据库中执行此操作
And Add this query to display data from MS-Access into dataGridView without ( <div>
) annoying tag并添加此查询以将 MS-Access 中的数据显示到 dataGridView 中,而无需 ( <div>
) 烦人的标签
OleDbConnection con = new OleDbConnection("your connection string");
OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
OleDbCommand cmd = new OleDbCommand();
private void getDataBtn_Click(object sender, EventArgs e)
{
cmd.Connection = con;
OleDbDataAdapter dataAdapter = new OleDbDataAdapter("SELECT * FROM [Table]", con);
DataTable dataTable = new DataTable();
dataAdapter.Fill(dataTable);
dataGridView1.DataSource = dataTable;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.