Help with Datagridviews

  • Thread starter Thread starter Mike Fellows
  • Start date Start date
M

Mike Fellows

Hi,

Im populating a datagridview with a dataset using

datagridview.datasource = dataset.tables(0)

and this works fine in most cases, except when my dataset has multiple lines
of text in a single row

for example if i had an address stored as below:

street
address2
town
county
postcode
country

the above address would just show the intial line, my question is then how
do I get the datagridview to autosize on row height to show all the
available information

Thanks in advance

Mike Fellows
 
Hi,

Here is a quick example. Set the datagridviews autosizerowsmode to
allcells


Dim strConn As String = _
"Server = .\SQLEXPRESS;Database = NorthWind; Integrated Security
= SSPI;"
Dim conn As New SqlConnection(strConn)
Dim da As New SqlDataAdapter("Select LastName, Notes from
Employees", conn)

da.Fill(dt)

DataGridView1.DataSource = dt
With DataGridView1.Columns("Notes")
.Width = 150
.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
.DefaultCellStyle.WrapMode = DataGridViewTriState.True
End With

Ken
 
Back
Top