0

this is my Access database

enter image description here

as you see in Blood Group Row I have a multiline in testUnit Column A+, A-, O+, O-, etc...

my problem is below

enter image description here

Why dataGridView display these lines text between divs ? I set Wrap-text true
but it doesn't solve my problem .. the expected output in datagridview

  • A+
  • A-
  • O+
  • O-

( without div tag )

I SOLVED THIS QUESTION AFTER CHANGE SOME THING IN DATABASE

DATATYPE of field (field used to store many lines in) SHOULD BE Long Text and make the TextFormat plain text as show below enter image description here

June7
  • 19,874
  • 8
  • 24
  • 34
Aiman
  • 33
  • 7
  • Is this not a duplicate of https://stackoverflow.com/questions/1706454/c-multiline-text-in-datagridview-control ? – Caius Jard May 09 '21 at 20:06
  • @CaiusJard i already see this question but it doesnt solve my problem – Aiman May 09 '21 at 20:10
  • Show how you get data into the datagridview – Caius Jard May 09 '21 at 20:23
  • I got this
    A+
    A-
    O+
    O-
     
    and I put a screenshot in my post
    – Aiman May 09 '21 at 20:27
  • @OlivierRogier unfortunately didnt solved my question.. I set ```default cell style > wrapmode true``` and nothing effected – Aiman May 09 '21 at 20:34
  • 2
    @Aiman, instead of editing question, could have written an answer and mark it accepted. – June7 May 09 '21 at 21:35
  • I VTC this question because it was effectively caused by a typo. In future, do not edit your question to include an answer; post your own answer. You're allowed to answer your own questions – Caius Jard May 10 '21 at 08:50

2 Answers2

0

When rebinding your columns, use Eval("testUnit") instead of bind. I remember this for you, i hope this is useful for you...

June7
  • 19,874
  • 8
  • 24
  • 34
Ali
  • 11
  • 2
0

Do this in your DataBase

enter image description here

And Add this query to display data from MS-Access into dataGridView without (<div>) annoying tag

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


Aiman
  • 33
  • 7