Gianmaria
10-12-2007, 05:02 AM
Hi,
i'm using textboxes to mark some places on the map customizing the text.
I use:
tbox = Shapes.AddTextbox(Location, 1, 1);
and later i modify the size to adapt to the text:
tBox.Width = getWidthByString(textToDisplay);
the getWidthByString is a my custom function that calculate the size analyzing the string and adding 11pts if a char is lower and 12pts if a char is upper:
private int getWidthByString(string name)
{
int w = 0;
foreach (char c in name)
{
if (Char.IsLower(c)) { w += 11; }
if (Char.IsUpper(c)) { w += 12; }
}
return w;
}
but this seem to dont have a regular behaviuor.. i always have txtboxes larger than i need....
Any Idea?
Gianmaria
i'm using textboxes to mark some places on the map customizing the text.
I use:
tbox = Shapes.AddTextbox(Location, 1, 1);
and later i modify the size to adapt to the text:
tBox.Width = getWidthByString(textToDisplay);
the getWidthByString is a my custom function that calculate the size analyzing the string and adding 11pts if a char is lower and 12pts if a char is upper:
private int getWidthByString(string name)
{
int w = 0;
foreach (char c in name)
{
if (Char.IsLower(c)) { w += 11; }
if (Char.IsUpper(c)) { w += 12; }
}
return w;
}
but this seem to dont have a regular behaviuor.. i always have txtboxes larger than i need....
Any Idea?
Gianmaria