Hi,
From a C# application am I writing some text in a Word.Table, in a Cell of
the Table to be more precise.
The cell has a certain width and any string written in the cell will cover
one or more lines in the cell depending on its length. In other words, it
will use wordwrapping
Now, I have to determine the amount of lines that the text will take when
written in the cell.
How can I do this ?
thnx
Chris 11 2758
where is your string coming from before you insert it into the table?
StringBuilder? String array?
need some more info/code snippet to help
Hi,
You can use Graphics.MeasureString but you need to know the font, another
problem is the wordwrapping , I bet you would have to build your own
wrapping algorith and see how many lines you get
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"cc" <cm****@yahoo.com> wrote in message
news:44***********************@news.skynet.be... Hi,
From a C# application am I writing some text in a Word.Table, in a Cell of the Table to be more precise.
The cell has a certain width and any string written in the cell will cover one or more lines in the cell depending on its length. In other words, it will use wordwrapping
Now, I have to determine the amount of lines that the text will take when written in the cell. How can I do this ?
thnx Chris
Hi,
it is just a string.
some code :
m_table1.Cell(3, 4).Width = 200;
m_table1.Cell(3, 4).Range.Text = "This is my test string. It's length can
vary..."
"dkode" <dk****@gmail.com> wrote in message
news:11**********************@j52g2000cwj.googlegr oups.com... where is your string coming from before you insert it into the table? StringBuilder? String array?
need some more info/code snippet to help
you can do the following:
string myString = "This is my test string. It's length can vary.";
m_table1.Cell(3, 4).Width = 200;
if (myString.Length > 200) {
// do processing or break apart the string into seperate lines I.E.
string stringPart = myString.Substring(0, 200);
string stringPart2 = myString.Substring(200, 200);
}
is this what your looking for?
Hi,
I don't think this is what the OP wants, he wants to know how many rows were
used to display the string when it was drawn in the screen.
The cell width is a pixel value, where the string length is in char, of
course one char does not fit in one pixel , so there is where the thing gets
nasty :)
OP:
See my other post to how to measure a string's representation in the screen
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"dkode" <dk****@gmail.com> wrote in message
news:11*********************@p10g2000cwp.googlegro ups.com... you can do the following:
string myString = "This is my test string. It's length can vary.";
m_table1.Cell(3, 4).Width = 200; if (myString.Length > 200) { // do processing or break apart the string into seperate lines I.E. string stringPart = myString.Substring(0, 200); string stringPart2 = myString.Substring(200, 200); }
is this what your looking for?
> "cc" <cm****@yahoo.com> wrote in message news:44***********************@news.skynet.be... Hi,
From a C# application am I writing some text in a Word.Table, in a Cell of the Table to be more precise.
The cell has a certain width and any string written in the cell will cover one or more lines in the cell depending on its length. In other words, it will use wordwrapping
Now, I have to determine the amount of lines that the text will take when written in the cell. How can I do this ?
thnx Chris
Ignacio Machin ( .NET/ C# MVP ) wrote: Hi,
You can use Graphics.MeasureString but you need to know the font, another problem is the wordwrapping , I bet you would have to build your own wrapping algorith and see how many lines you get
Or give it the dimensions of the cell..
Overloads Public Function MeasureString( _
ByVal text As String, _
ByVal font As Font, _
ByVal layoutArea As SizeF _
) As SizeF
:-)
There is an overloaded .measurestring method that allows passing it the width
and returning the size which will give you the height. Divide this by the
font height and you will get the no. of lines.
--
Dennis in Houston
"dotNuttah" wrote: "cc" <cm****@yahoo.com> wrote in message news:44***********************@news.skynet.be... Hi,
From a C# application am I writing some text in a Word.Table, in a Cell of the Table to be more precise.
The cell has a certain width and any string written in the cell will cover one or more lines in the cell depending on its length. In other words, it will use wordwrapping
Now, I have to determine the amount of lines that the text will take when written in the cell. How can I do this ?
thnx Chris
Ignacio Machin ( .NET/ C# MVP ) wrote: Hi,
You can use Graphics.MeasureString but you need to know the font, another problem is the wordwrapping , I bet you would have to build your own wrapping algorith and see how many lines you get
Or give it the dimensions of the cell..
Overloads Public Function MeasureString( _ ByVal text As String, _ ByVal font As Font, _ ByVal layoutArea As SizeF _ ) As SizeF
:-)
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.com... There is an overloaded .measurestring method that allows passing it the width and returning the size which will give you the height. Divide this by the font height and you will get the no. of lines. --
Sure, that will work.
As long as you don't mind silly little things like line breaks in mid character.
You really need a more involved algorithm to do proper word wrapping.
Bill
Hello, Chris,
Just a thought...
Do you really need to know the number of lines before you write to the
cell? Or could you write to the cell, and then ask: "How many lines are
in the cell?"
Cheers,
Randy
cc wrote: Hi,
From a C# application am I writing some text in a Word.Table, in a Cell of the Table to be more precise.
The cell has a certain width and any string written in the cell will cover one or more lines in the cell depending on its length. In other words, it will use wordwrapping
Now, I have to determine the amount of lines that the text will take when written in the cell. How can I do this ?
thnx Chris
It's really a pretty simple algorthim to break the string into multiple
strings at the line breaks then use measurestring on each substring and add
in lines for each line break. The user should be able to extrapolate from
measurestring method to this algorthim.
--
Dennis in Houston
"Bill Butler" wrote: "Dennis" <De****@discussions.microsoft.com> wrote in message news:F7**********************************@microsof t.com... There is an overloaded .measurestring method that allows passing it the width and returning the size which will give you the height. Divide this by the font height and you will get the no. of lines. --
Sure, that will work. As long as you don't mind silly little things like line breaks in mid character.
You really need a more involved algorithm to do proper word wrapping.
Bill
That might be an option...
But I'll probably have a look at the Graphics.Measuestring()
thanks to all of you !
Chris
"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44***********************@news.wanadoo.nl... Hello, Chris,
Just a thought...
Do you really need to know the number of lines before you write to the cell? Or could you write to the cell, and then ask: "How many lines are in the cell?"
Cheers, Randy
cc wrote: Hi,
From a C# application am I writing some text in a Word.Table, in a Cell
of the Table to be more precise.
The cell has a certain width and any string written in the cell will
cover one or more lines in the cell depending on its length. In other words,
it will use wordwrapping
Now, I have to determine the amount of lines that the text will take
when written in the cell. How can I do this ?
thnx Chris
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: John Smith |
last post by:
Hi,
I'm writing a library in C++ which is supposed to be used by people using C.
One function I have must return a string to users which is arbitrary length.
The user must be able to use this...
|
by: MLH |
last post by:
I'm working with lots of long strings now, it seems.
I have to import them & parse them constantly. The
A97 memo field type supports only 32768 chars.
What happens when this is processed...
Dim...
|
by: Jimski |
last post by:
Hello all,
I am having a problem where I get an error message when I call
FlushFinalBlock when decrypting my encrypted text. I am using the
Rijndael algorithm.
The error message is "Length...
|
by: gane kol |
last post by:
Hi
I am using DES algorithm. I am getting an error message in a few cases of
the querystring
Error Message : Length of the data to decrypt is invalid.
Error Method : System.String...
|
by: Matt |
last post by:
Have below code
AcctNbr give me result of 30.
That is the database column length, Column stores 10 why is giving me
30 ?
while(objRead.Read())
{
AcctNbr = (string)objRead.ToString().Length;...
|
by: Lyle Fairfield |
last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp
"If the value of the variant argument is Null, the Nz function returns
the number zero or a...
|
by: Mavenos |
last post by:
Hi Web Masters,
Just wondering wether you can help us to come up with some tokenize
script.
My problem is wanted to display a LONG content into a short para (by
giving minimum letter lenght)...
|
by: Sathyaish |
last post by:
I have the following scenario:
Algorithm: 3DES
Cipher Mode: CBC
Key Size: 128-bit
Block Size: 64 bit
IV: 0x0000000000000000 (an eight byte array of zeros)
The results I get using .NET with...
|
by: kellygreer1 |
last post by:
What is a good one line method for doing a "length safe"
String.Substring?
The VB classes offer up the old Left function so that
string s = Microsoft.VisualBasic.Left("kelly",200)
// s will =...
|
by: Rick Knospler |
last post by:
I am trying to convert a vb6 project to vb.net. The conversion worked for
the most part except for the fixed length strings and fixed length string
arrays. Bascially the vb6 programmer stored all...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |