Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Distributed Applications / February 2004

Tip: Looking for answers? Try searching our database.

wordwrap in datagrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul N - 28 Jan 2004 23:17 GMT
How can I stop sentences in datagrids from wrapping? I
have set the wrap property to false, but it makes no
difference.

   Thanks for any help,

       Paul.
MSFT - 29 Jan 2004 08:19 GMT
Hi Paul,

Thank you for using the community. Regarding the question, is it a Windows
Form DataGrid control or a Web Form DataGrid control?

Luke
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Paul N - 29 Jan 2004 14:49 GMT
Hi Luke,

 It's a webform datagrid.
MSFT - 30 Jan 2004 06:29 GMT
Hi Paul,

By default, the text in ASP.NET DataGrid woundn't be wrapped. The problem
may be related to other settings on the webform. You may first check if the
DataGrid control is embeded in other controls or HTML component, for
example, a Panel or <DIV>. And check if the Wrap property is set on these
component.

Secondly, you can check following KB article:

BUG: DataGrid Web Server Control Wraps When ItemStyle Wrap or HeaderStyle
Wrap Property Is Set to False in Visual Basic .NET
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q323169

To see it can help.

If above suggestions didn't help, Can you post the HTML code for the
DataGrid? This may help us perform deeper research on the issue.

Luke
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Paul N - 30 Jan 2004 22:47 GMT
>-----Original Message-----
>Hi Paul,
[quoted text clipped - 24 lines]
>
>.

Sorry, Luke, but this doesn't work. My datagrid is
dynamically generated - not pre determined. I dynamically
build a datatable, and make this the source for the
datagrid. The datatable is not directly obtained from the
database - it comes from a set of objects which either are
made from DB derived data, or other objects made from
these objects. I want to be able to hide columns also,
which is being a real pain too. Columns in the data table
don't have a "No Wrap" property, and so can't be set
there. They also don't have a "visible" propert to make
false. The datagrid only accesses columns by index, and
only indexes the hard coded columns in the page (of which
I have none).

   Please help!

       Paul.
MSFT - 02 Feb 2004 08:23 GMT
Hi Paul,

If we add DataColmn to the DataGird, we can control the Wrap property of a
column. Please refer to following sample:

Dim dt As New DataTable("MyTable")

       Dim dc As New DataColumn("id", System.Type.GetType("System.Int16"))
       dt.Columns.Add(dc)

       dc = New DataColumn("name", System.Type.GetType("System.String"))
       dt.Columns.Add(dc)

       dc = New DataColumn("age", System.Type.GetType("System.Int16"))
       dt.Columns.Add(dc)

       Dim dr As DataRow = dt.NewRow()

       dr(0) = 1
       dr(1) = "Luke"
       dr(2) = 35

       dt.Rows.Add(dr)

       dr = dt.NewRow()

       dr(0) = 2
       dr(1) = "My name is Luke, my id is 2, my age is 36;My name is Luke,
my id is 2, my age is 36"
       dr(2) = 36

       dt.Rows.Add(dr)

       Dim dg As New DataGrid

       dg.Visible = True

       dg.AutoGenerateColumns = False

       Dim dgc As New BoundColumn
       dgc.HeaderText = "ID"
       dgc.DataField = "id"
       dg.Columns.Add(dgc)

       dgc = New BoundColumn
       dgc.HeaderText = "Name"
       dgc.DataField = "name"

       dgc.ItemStyle.Wrap = False

       dg.Columns.Add(dgc)

       dgc = New BoundColumn
       dgc.HeaderText = "age"
       dgc.DataField = "age"
       dg.Columns.Add(dgc)

       dg.DataSource = dt

       dg.DataBind()

       Me.Controls.Add(dg)

       'dg.Columns(2).Visible = False

And, as you have seen, to hide a column, we can call "dg.Columns(2).Visible
= False"

Luke
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Paul N - 02 Feb 2004 17:30 GMT
Thanks very much, Luke - that's my problem solved.

Paul Nelson.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.