[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

(Robert)

12/25/2002 10:26:00 PM

Hi!
I try to build a webcontrol, which displays some textstrings, read
from a database, into a table's columns. Now, if the text is to large
for the column, it its broken into several lines and the column is
extended in height. If I set the nowrap-attribut for the column, the
text is displayed in a single line, but the column will be extended in
width. In this case, it is important, that the size of the tablecolumn
are not changing. I am looking for some code, that will shorten the
text when it is to large for its destination and add a couple of
points to the end (e.g. "this is a very long text" will lead to "this
is a very...")


Any ideas?
Thx, Robert
2 Answers

Victor Garcia Aprea [MVP]

12/18/2002 8:50:00 AM

0

Hi Robert,

Have you tried something like this?

[C#]
if(str.Length>10)
str = str.Substring(0,10) + "...";

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.


"Robert" <robert.dehmel@spk-pforzheim.de> wrote in message
news:5a78ef13.0212170735.69176c71@posting.google.com...
> Hi!
> I try to build a webcontrol, which displays some textstrings, read
> from a database, into a table's columns. Now, if the text is to large
> for the column, it its broken into several lines and the column is
> extended in height. If I set the nowrap-attribut for the column, the
> text is displayed in a single line, but the column will be extended in
> width. In this case, it is important, that the size of the tablecolumn
> are not changing. I am looking for some code, that will shorten the
> text when it is to large for its destination and add a couple of
> points to the end (e.g. "this is a very long text" will lead to "this
> is a very...")
>
>
> Any ideas?
> Thx, Robert


(Scott)

12/25/2002 10:27:00 PM

0

Robert, you may want to check out this article on 4Guys:

Creating a Custom DataGrid Column Class
http://aspnet.4guysfromrolla.com/articles/100...

It shows how to create a custom DataGrid column class that has a
property CharacterLimit that limits a string to a set number of
characters (without breaking a word in half).

Also, if you are not wanting to do it in a DataGrid, the author (John
Dyer) shows source code that you can use directly in your ASP.NET Web
page to truncate a string (code written in C#, btw).

Happy Programming!

Scott Mitchell
http://www.4GuysFro...


robert.dehmel@spk-pforzheim.de (Robert) wrote in message news:<5a78ef13.0212170735.69176c71@posting.google.com>...
> Hi!
> I try to build a webcontrol, which displays some textstrings, read
> from a database, into a table's columns. Now, if the text is to large
> for the column, it its broken into several lines and the column is
> extended in height. If I set the nowrap-attribut for the column, the
> text is displayed in a single line, but the column will be extended in
> width. In this case, it is important, that the size of the tablecolumn
> are not changing. I am looking for some code, that will shorten the
> text when it is to large for its destination and add a couple of
> points to the end (e.g. "this is a very long text" will lead to "this
> is a very...")