473,320 Members | 2,104 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,320 software developers and data experts.

Wrapping text in a DataGrid Cell

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
Nov 15 '05 #1
3 7141
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" <te**@temp.com> wrote in message
news:uH**************@TK2MSFTNGP09.phx.gbl...
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


Nov 15 '05 #2
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" <te**@temp.com> wrote in message
news:uH**************@TK2MSFTNGP09.phx.gbl...
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

Nov 15 '05 #3
Thanks for the help...Have a good day

"Randy" <te**@temp.com> wrote in message
news:uH**************@TK2MSFTNGP09.phx.gbl...
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

Nov 15 '05 #4

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

Similar topics

12
by: sneill | last post by:
Hello, I have the following HTML / CSS that draws 2 rows. Each row has 3 cells. I want the cells within each row to span a single line. Each cell is 100px wide, and the row containing them is...
1
by: Sangeetha | last post by:
I have a datagrid column which I want to expand when i type in some text. Initially I tried increasing the column width on the key down event of that DataGridTextBoxColumn, but it didn't work out as...
0
by: Frnak McKenney | last post by:
One of the reasons given for the Allied victory in WWI is that the Nazi armament industry invested so much effort in creating new weapons (e.g. the jet plane) it wasn't able to develop any of them...
2
by: martin | last post by:
Hi, I am iterating through the dataitems in a datagrid and producing and xml document, If a particular cell in the datagrid has a textbox control or a datagrid control in it then I have no...
4
by: rodchar | last post by:
Hey all, I have a datagrid that auto-generate the columns. When I run the app some of the column values are wrapping. How do I prevent the values from wrapping? Do I have to use template...
5
by: Brian Henry | last post by:
I have a messaging application that has a data grid with information like an email list would have (from, subject, time sent, size) but the subject could be very long in theory, and then it would...
1
by: Tracey | last post by:
Hi, there My application requires to display multiline text in the cell of datagrid. I set the preferredheight of datagrid's tablsstyle, however, it is fixed. For text longer than that, the rest...
2
by: niceguy | last post by:
Hi I was wondering if its possible to get the exact displayed text from a cell in a datagrid. I need to get the displayed text and not any 'real' database value or anything that the cell...
2
by: amitp | last post by:
hi i'm using MS Word2003 for my VB application which is a report. The word documents contains tables and the cells inside the table contain some fields. My application replaces the field values with...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.