简体   繁体   中英

data not being save with crlf so it's all one line

I am using a varchar(max) in a column of datatable. I am then populating my datagridview with the query.

Everything is going fine getting the data to the dgv. The problem is my crlf are not displaying correctly in the datagridview.

It is displaying all as one line of text.

For example:

Starting GetWebsiteSettings.
Starting GetTokenShowHideSettings.
End GetTokenShowHideSettings.
End GetWebsiteSettings.

Is displaying as

Starting GetWebsiteSettings.Starting GetTokenShowHideSettings.End GetTokenShowHideSettings.End GetWebsiteSettings.

This is how I am populating the 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;

  }
}

How do I get the datagridview to display the text correctly?

I found this post

dataGridView1.Columns["Message"].DefaultCellStyle.WrapMode = 
                                                      DataGridViewTriState.True;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM