我在数据表的列中使用 varchar(max)。然后我用查询填充我的datagridview。
将数据传输到 dgv 一切正常。问题是我的 crlf 在 datagridview 中显示不正确。
它全部显示为一行文本。
例如:
Starting GetWebsiteSettings.
Starting GetTokenShowHideSettings.
End GetTokenShowHideSettings.
End GetWebsiteSettings.
显示为
Starting GetWebsiteSettings.Starting GetTokenShowHideSettings.End GetTokenShowHideSettings.End GetWebsiteSettings.
这就是我填充 dgv 的方式:
private void button_Search_Click(object sender, EventArgs e)
{
using (var model = new SuburbanPortalEntities())
{
var qry = from logs in model.Logs
select logs;
Guid corpid;
if (Guid.TryParse(textBox_CorporationGuid.Text, out corpid))
{
qry = qry.Where(x => x.CorporationId == corpid);
}
Guid tokenid;
if (Guid.TryParse(textBox_TokenId.Text, out tokenid))
{
qry = qry.Where(x => x.TokenId == tokenid);
}
if (checkBox_DisplayErrors.Checked)
{
qry = qry.Where(x => x.IsException);
}
if (checkBox_DisplayWarnings.Checked)
{
qry = qry.Where(x => x.IsWarning);
}
qry = qry.OrderBy(x => x.LogDateTime);
dataGridView1.DataSource = qry;
dataGridView1.Columns["LogId"].Visible = false;
dataGridView1.Columns["ClientHeaders"].Visible = false;
dataGridView1.Columns["SourceId"].Visible = false;
}
}
如何让 datagridview 正确显示文本?