473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help with Datagridviews

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
Jun 9 '06 #1
2 1685
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

Jun 9 '06 #2
Thanks Ken

Worked a treat

Cheers

Mike Fellows
"Ken Tucker [MVP]" <Ke**********@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.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

Jun 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
3
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With...
0
by: Susan Mackay | last post by:
I have an application that works well, with two DataGridViews connected with the necessary BindingSources, DataTables etc to have one DataGridView act as the parent and the other as the child in...
3
by: TomH | last post by:
I am using VB within VS 2005. How can I have multiple datagridviews on the same form pulling from the same table? e.g. I want to see all clients from New York in one view and all clients from LA in...
0
by: Catnip | last post by:
Hi and thanks in advance I am having trouble with a cinema system I am creating in VB.NET. I have a form called frmSales which has three datagridviews on it which are linked to a Cinema.mdb...
0
by: Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+ | last post by:
I have a DataGridView control that is being populated by a database manually, not by being data bound). However, I need to run an algorithm based on a few columns of data for every row in the grid,...
5
by: firejunior88 | last post by:
Hello, my first post: Sorry if this is a noob question. I have a problem. I have added a database to my project in Visual Studio 2005. I created my tables, and threw in some data to do some...
0
by: Chris | last post by:
I have two datagridviews on a form that are linked via a datarelation. I am using: "foreach ( DataGridViewRow tripRow in scenario_TripsDataGridView.Rows )" to loop thru all the rows in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.