|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Help with DatagridviewsIm 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 ------------------------------------ Show quoteHide quote "Mike Fellows" wrote: > 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 > > > Thanks Ken
Worked a treat Cheers Mike Fellows Show quoteHide quote "Ken Tucker [MVP]" <KenTucker***@discussions.microsoft.com> wrote in message news:65D790E1-2A02-4028-B4B8-4CEF47FEA514@microsoft.com... > 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 > ------------------------------------ > > "Mike Fellows" wrote: > >> 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 >> >> >>
Changing text in Report viewer
Threading Advice SQL Express or MDB - opinions please ExecuteNonQuery Wierdness Evaluating threads in an application dll & Web Service in VB.Net 2005 Stored Procedure Reading - Parsing Records From An LDAP LDIF File In .Net? Class/Structure/Enum Converting OLE Automation Dates back into regular date/time? Data Reader |
|||||||||||||||||||||||