PC Review


Reply
Thread Tools Rate Thread

Wrapping text in a DataGrid Cell

 
 
Randy
Guest
Posts: n/a
 
      1st Oct 2003
Hello,
How would this be done? I've looked at the datagrid itself and also the
tableStyle and can't find out how to make text wrap in a cell.
Thanks


 
Reply With Quote
 
 
 
 
Dmitriy Lapshin [C# / .NET MVP]
Guest
Posts: n/a
 
      2nd Oct 2003
Hi Randy,

When a cell is not being edited, its conent is painted with the
corresponding DataGridColumnStyle's Paint method (there are several
overloads). When it is being edited, cell appearence is in hands of a user
control used to edit the cell contents - most likely this will be a TextBox.

So what you need is inheriting from
System.Windows.Forms.DataGridTextBoxColumn and overriding its Paint method
to enable wrapping. You might also need to overload column style methods
responsible for calculating the row height - the grid won't be able to
adjust the row height upon double-click between row headers otherwise. To
make the text wrap during editing, you will need to tweak the hosted
TextBox - probably it should be switched to the MultiLine mode, but I am not
so sure here.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Randy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
> How would this be done? I've looked at the datagrid itself and also the
> tableStyle and can't find out how to make text wrap in a cell.
> Thanks
>
>


 
Reply With Quote
 
 
 
 
Michael Earls
Guest
Posts: n/a
 
      3rd Oct 2003
Hi Randy,

The best way to solve any layout problem is to use CSS.

Set the CSS class of the cell to a CSS class that has the following
definition:

..nowrap{
white-space: nowrap;
}


or, you could set the inline style attribute to style="white-space:
nowrap;", but this is not supported in older Netscape browsers.

Look at the cell columns properties and set the class there if at all
possible.

Michael Earls



"Randy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
> How would this be done? I've looked at the datagrid itself and also the
> tableStyle and can't find out how to make text wrap in a cell.
> Thanks
>
>



 
Reply With Quote
 
Randy
Guest
Posts: n/a
 
      6th Oct 2003
Thanks for the help...Have a good day

"Randy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
> How would this be done? I've looked at the datagrid itself and also the
> tableStyle and can't find out how to make text wrap in a cell.
> Thanks
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text does not display in "Text boxs" and when wrapping text in a c =?Utf-8?B?RXN0ZWJhbg==?= Microsoft Excel Misc 1 9th Mar 2007 12:59 AM
MS work around on text wrapping in a datagrid does not work TB Microsoft ASP .NET 2 22nd Feb 2006 11:34 PM
To stop text wrapping in an datagrid asp.net 2003 Dan Microsoft ASP .NET 0 25th Feb 2005 07:34 AM
wrapping text in datagrid cells Tim Roop Microsoft Dot NET Framework Forms 3 4th Mar 2004 03:15 PM
Wrapping Text in Column of Windows DataGrid Control =?Utf-8?B?R2FuZXNoIE5heWFr?= Microsoft Dot NET Framework Forms 1 5th Feb 2004 09:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:24 AM.