473,804 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7168
Hi Randy,

When a cell is not being edited, its conent is painted with the
corresponding DataGridColumnS tyle'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.DataGridT extBoxColumn 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.co m> wrote in message
news:uH******** ******@TK2MSFTN GP09.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.co m> wrote in message
news:uH******** ******@TK2MSFTN GP09.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.co m> wrote in message
news:uH******** ******@TK2MSFTN GP09.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
19529
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 250px wide. Clearly the last cell won't fix, but rather than wrapping to the next 'line' within the row, I'd like the last cell to be clipped and only showing the first 50px. This code was developed in IE6. Can't say what it looks like in
1
8773
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 expected. Now, I am trying to increase the height of the row to make it as a multiline column. private DataGridTextBoxColumn dgcComments dgcComments = new DataGridTextBoxColumn() dgcComments.TextBox.Multiline = true...
0
1824
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 to the point of mass-production. There are days when I experience the same difficulties with C# and dotNET: there are twelve ways to do 'most _any_thing, and I wind up exploring six before I find an acceptable solution. <grin> Case in...
2
1598
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 problem retrieveing it value by casting with CTYPE however when the datagrid cell contains no control, but does contain text, then I am having great trouble accessing its value.
4
1922
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 columns to accomplish this feat? thanks, rodchar
5
3516
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 word wrap.. the subject is a variable width column (resizes to fit space) while the others are fixed size... the problem is that i dont want the text to ever word wrap.. but truncate the visible subject to match the current cell width... (kinda...
1
6724
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 of text is cut missing. Can someone tell me how to do that? thanks.
2
1607
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 might contain in the background. I've tried getting to get the text through the datagrid's control
2
2299
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 Values from database. The problem i was getting is if the text length that is replaced is more than the cell length it was not displaying at all rather "Display Text Cannot Span More Than One Line" is displayed in that cell. I need to wrap the...
0
10353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10099
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.