DrawString problem

  • Thread starter Thread starter Tomer
  • Start date Start date
T

Tomer

Hi,

I'm using the LinkLabel in the SDF, when a long string is entered as Text
(without spaces) you can see in the designer that it gets cutted and
continued on the next line. But when you run your application the text
doesn't cutted off at all, like in the designer.

I've hoped that sp3 will solve this problem, but it didn't.

How do we deal with this problem??

Tomer.
 
As you probably have noticed, the device will handle text wrapping within
the LinkLabel, just not when the text is one giant word or a series of words
without spaces between them. Since the DrawString overloads are limited in
what we can accomplish through the CF, for example no overload is supported
that accepts a StringFormat, this is the only wrapping option unless you are
willing to code your own. Is there a great need to have a really long
string?
 
I need to display a 34 digit code in a large font on the device, so it is
needed to break the string.



Tomer.
 
At this point the only solution that I can think of would be to write some
custom code to determine the length of the string and then manually insert a
line break.
 
How about:

string myString;

string dispString = string.Join(
new string[] {
myString.SubString(0, 8),
myString.SubString(8, 8),
myString.SubString(16, 8),
myString.SubString(24, 8),
myString.SubString(32)
}, " ");

label1.Text = dispString;
 
The label is not with fixed font so I don't know how many chars would enter
in a line.
The solution would need to be more dynamic.

Tomer.

Alex Feinman said:
How about:

string myString;

string dispString = string.Join(
new string[] {
myString.SubString(0, 8),
myString.SubString(8, 8),
myString.SubString(16, 8),
myString.SubString(24, 8),
myString.SubString(32)
}, " ");

label1.Text = dispString;

--
Alex Feinman
---
Visit http://www.opennetcf.org
Tomer said:
I need to display a 34 digit code in a large font on the device, so it is
needed to break the string.



Tomer.
 
It is usually quite complicated task to measure text extents properly. What
I was trying to suggest by the code snippet is to find a number of
characters that definitely fits your screen horizontally and stick to it.

--
Alex Feinman
---
Visit http://www.opennetcf.org
Tomer said:
The label is not with fixed font so I don't know how many chars would
enter in a line.
The solution would need to be more dynamic.

Tomer.

Alex Feinman said:
How about:

string myString;

string dispString = string.Join(
new string[] {
myString.SubString(0, 8),
myString.SubString(8, 8),
myString.SubString(16, 8),
myString.SubString(24, 8),
myString.SubString(32)
}, " ");

label1.Text = dispString;

--
Alex Feinman
---
Visit http://www.opennetcf.org
Tomer said:
I need to display a 34 digit code in a large font on the device, so it is
needed to break the string.



Tomer.


"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in
message As you probably have noticed, the device will handle text wrapping
within
the LinkLabel, just not when the text is one giant word or a series of
words
without spaces between them. Since the DrawString overloads are limited
in
what we can accomplish through the CF, for example no overload is
supported
that accepts a StringFormat, this is the only wrapping option unless
you are
willing to code your own. Is there a great need to have a really long
string?

--
Tim Wilson
.Net Compact Framework MVP

Hi,

I'm using the LinkLabel in the SDF, when a long string is entered as
Text
(without spaces) you can see in the designer that it gets cutted and
continued on the next line. But when you run your application the text
doesn't cutted off at all, like in the designer.

I've hoped that sp3 will solve this problem, but it didn't.

How do we deal with this problem??

Tomer.
 
Gotcha. Thanks for the help, you're doing a great job!!

Tomer.

Alex Feinman said:
It is usually quite complicated task to measure text extents properly.
What I was trying to suggest by the code snippet is to find a number of
characters that definitely fits your screen horizontally and stick to it.

--
Alex Feinman
---
Visit http://www.opennetcf.org
Tomer said:
The label is not with fixed font so I don't know how many chars would
enter in a line.
The solution would need to be more dynamic.

Tomer.

Alex Feinman said:
How about:

string myString;

string dispString = string.Join(
new string[] {
myString.SubString(0, 8),
myString.SubString(8, 8),
myString.SubString(16, 8),
myString.SubString(24, 8),
myString.SubString(32)
}, " ");

label1.Text = dispString;

--
Alex Feinman
---
Visit http://www.opennetcf.org
I need to display a 34 digit code in a large font on the device, so it
is needed to break the string.



Tomer.


"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in
message As you probably have noticed, the device will handle text wrapping
within
the LinkLabel, just not when the text is one giant word or a series of
words
without spaces between them. Since the DrawString overloads are
limited in
what we can accomplish through the CF, for example no overload is
supported
that accepts a StringFormat, this is the only wrapping option unless
you are
willing to code your own. Is there a great need to have a really long
string?

--
Tim Wilson
.Net Compact Framework MVP

Hi,

I'm using the LinkLabel in the SDF, when a long string is entered as
Text
(without spaces) you can see in the designer that it gets cutted and
continued on the next line. But when you run your application the
text
doesn't cutted off at all, like in the designer.

I've hoped that sp3 will solve this problem, but it didn't.

How do we deal with this problem??

Tomer.
 
Back
Top