0

I am using windows forms C#.

I am trying to wrap a text into a datagridview cell but the text does not get wrapped.

I enabled the wrap mode and I set the datagridview Rows to autoSize but the wraping still did not work

DataGridView.AutoSizeRowsMode = True;

dataGridView1.DefaultCellStyle.WrapMode = True;

It works only if I add "\n" somewhere in the text for example:

dataGridView1.SelectedRows[0].Cells[1].Value = "123456" +"\n" + "ABCDE";

But as shown in the screenshot it does not wrap if I enter this text into the cell with no "\n" :

dataGridView1.SelectedRows[0].Cells[1].Value = "123456789ABCDEFGHIJKLMN"

screenshot

Anyone knows what is wrong or how can I enable cell wrapping without using \n? please help . Thank you

Community
  • 1
  • 1
Kate
  • 935
  • 4
  • 14
  • 34
  • See http://stackoverflow.com/questions/4847993/how-to-set-the-datagridviewcell-to-automatically-word-wrap – vcsjones Feb 19 '16 at 18:10
  • @ vcsjones . I already see this question and did not work. I sat dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells and it did not wrap . column1 pushed another column out of the DGV but no wrap. any idea? – Kate Feb 19 '16 at 18:17
  • I think it will wrap the next word...but in your case it is big one word...Split that word by putting space... – Viru Feb 19 '16 at 18:25
  • @Kate, Try DataGridView.Column[1].ItemStyle-Wrap = 'False' Or 'True' . – Software Enginner Feb 19 '16 at 21:11

0 Answers0