Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Moving Labels

edited October 2003 in General
RB v 6.03


I change the text value of a TppLabel in the OnGetText event in the object
inspector. I have another label component right next to the label I have
changed and I want to shift its left position relative to the size of the
changed label. i.e.

MovingLabel.Left := ChangedLabel.Left + ChangedLabel.Width + .125;

However when I do this the label I am moving does not move.

I have tried this in the same event procedure right after I have changed the
Text of the Changed Label.

And I have also tried to do it in the OnPrint event with no success.

Is this possible to do? If so what am I missing?

Bill

Comments

  • edited October 2003
    Please disregard this post. I forgot to place the 0.125 in my formula.
    Delete it from the newsgroup if you like.

    Bill


  • edited October 2003
    Please undisregard this message. I did add the 0.125 and it did not make a
    difference. Just lucky placement when I designed the report. When the
    changing label was longer or shorter it didn't move.

    So please consider the original post as a valid question.

    Bill
  • edited October 2003
    Hi Bill,

    You need to use the Band.OnBeforePrint event to move labels around rather
    than the Label.OnPrint. This should change the results you are getting.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2003
    I tried using the Band.OnBeforePrint event and still no change.
    I also assigned the caption in the OnBeforePrint event of the band before
    moving my labels to see if that would work and they still didn't move.

    Bill
  • edited October 2003
    Hi Bill,

    Please send an example with the code you use to try to move the label in
    .zip format to support@digital-metaphors.com and I'll take a look at it for
    you.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2003
    Actually the code is almost exactly the same as what I put in my earlier
    post. Just with my names for the components.

    This is the name of the procedure that the IDE generated for the
    OnBeforePrint event
    other than that the code in my earlier post is exactly what I put in there.

    procedure TfmMyForm.ppTitleBand1BeforePrint(Sender: TObject);

    Bill
  • edited October 2003
    Hi Bill,

    I created a small app to test this and it seemed to work correctly. Below
    is a link to the test application I created to test with. Let me know if
    you get different results than I do.

    http://www.digital-metaphors.com/tips/MoveLabel.zip

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2003
    Back at ya! It looks like labels can't move in the Title Band.


  • edited October 2003
    I have found the cause of the problem. It has to do with the label
    autosizing itself.
    I have attached an example of what it is doing.
    Complile the example and then type in a long string of text in the edit box.
    Then type in a short 4 letter string.

    You will see that the moving label will only move to the position to the
    right of the original width of the label.

    So my actual question is this. Is it possible after setting the text value
    of a label to get the width property updated so that the true with of the
    control is reflected?

    Bill


  • edited October 2003
    Hi Bill,

    Try downloading the example again. I changed it to move the label based on
    the text width, not the control box. This seems to work around the autosize
    issue.

    http://www.digital-metaphors.com/tips/MoveLabel.zip

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.