Then you are doing something incorrect from what I gave you and indicated to read the instructions.
Example, I took the example given to you and replaced the static lines of filling the DataTable rows with a dynamic method of reading a Text File and it worked just fine as suspected.
Code:
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.AddRange(New DataColumn() _
{New DataColumn("Identifier", GetType(System.Int32)), _
New DataColumn("Field1", GetType(System.String))})
Dim Request = (From line In IO.File.ReadAllLines("Document.txt") _
Where line.Length > 0 _
Let Items = line.Split(","c) _
Select New With _
{.ID = Items(0), _
.Text = Items(1) _
} _
).ToList
For Each line In Request
dt.Rows.Add(New Object() {line.ID, line.Text})
Next
DataGridView1.DataSource = dt
DataGridView1.Columns.Item("Column2").DefaultCellStyle.WrapMode = DataGridViewTriState.True
End Sub
Contents of Document text which has line breaks is attached.
Thanks kevininstructor for your answer. The problem is when I update data grid, I first run with short string data (no wrap need) then I modify data to need wrap,but the grid doesn't do that automatically.
I've attached again the sample,this time I used your txt file and code,I just create a second string column and put there first 10 caracter from column 1 in order to have initial no wrapping needed.
Run the sample and press Modify data button,there I put column 1 (long) into 2 (short text) but the grid doesn't refresh automatically,no wrap is done
Changing properties of the DataGridView will not help in this case, instead you need to work at the DataSource level, the DataTable then tell the BindingSource as shown below.
Code to make this work is marked in red. Note I took some of your code out.
Code:
Public Class Form1
Dim dt As New DataTable
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
dt.Columns.AddRange(New DataColumn() _
{New DataColumn("Identifier", GetType(System.Int32)), _
New DataColumn("Field1", GetType(System.String)), New DataColumn("Field2", GetType(System.String))})
Dim Request = (From line In IO.File.ReadAllLines("Document.txt") _
Where line.Length > 0 _
Let Items = line.Split(","c) _
Select New With _
{.ID = Items(0), _
.Text = Items(1) _
} _
).ToList
For Each line In Request
dt.Rows.Add(New Object() {line.ID, line.Text, line.Text.Substring(0, 10)})
Next
dt.AcceptChanges()
BindingSource1.DataSource = dt
DataGridView1.Columns(0).DefaultCellStyle.WrapMode = DataGridViewTriState.True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DirectCast(BindingSource1.Current, DataRowView)("Field2") = dt.Rows(0)("Field1").ToString
DirectCast(BindingSource1.DataSource, DataTable).AcceptChanges()BindingSource1.ResetCurrentItem()
End Sub
End Class