Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Label behavior 1

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,826
JP
I rarely find the need to change a label after it's already established, but I do have one issue on an application requirements at a "global" level.

In the attempt to keep all my users happy, on a global level, geographic boundaries are not all called the same thing. For example, in the US a major boundary is called a "State", in Japan, they are called "Prefectures", in Australia, they may be either a "State" or a "Territory". The UK uses "County" in many cases (Not to confuse US county boundaries as well, but they are typically not "postally significant".

So I have created the ability to change the label dynamically based on the city (which auto populates, State, country and region as well as contains the "Boundary Label Tag".

It all works fine... except for one weird behavior on the label.
I have set as the default for the label to align to the right (with space at left to hold larger labels than the default "Prefecture", as it's the largest label, but it gets changed immediately to whatever the Boundary Tag is set to, and it's "Visible" property is set to off, until an address record actually has a value for State (as many don't, like Singapore, Hong Kong, Saudi Arabia, etc.)

The problem is, it seems to be "centering" the label entry, despite forcing a This.lblStateTag.Alignment = 1 just before changing the tag. It continues to (at least appear) to center them.

Is there some trick I need to employ to keep the right edge of the label in place? This keeps them exactly 6 pixels from the text box that's next to it, and if it doesn't align, then it looks very wonky (that's an Australian term for "out of whack".)


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Is the caption you set RTRIM()ed at least?

I never had any problems with the alignment of labels, there is a bug known for transparent labels to get a blurry edge after some refreshes and repaints, a problem of cleartype and gdiplus, but that has nothing to do with alignment. The easiest fault would be your captions have some trailing spaces, which - even though right aligned - cause extra distance to the labels right edge. As values you get from char fields typically are left trimmed you never see the effect of the trailing spaces on left aligned labels, but trailing spaces get apparent on right aligment, and if it's always just a few it might look as centered alignment.

If ALLTRIM() doesn't do the job check out the alignment at the time the label is made visible. Any stray .SETALL() calls could influence properties, for example.

Bye, Olaf.
 
Ah, you know that might be it.
Let me try it.


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
That was it! I ALLTRIM() it instead just to make sure no extra stuff floating around. Worked like a charm.
Feeling exceptionally stupid now.

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top