Options

Image won't refresh in PictureBox

Saint-SageSaint-Sage Member Posts: 92
Hello everyone,

I have a picturebox on a form which I am trying to populate with a high-quality image. I cannot just load it into the bitmap property because it is so large.

I have a little problem. If I import the file directly into a BLOB table field which I am using as the source for the picturebox, it shows. However, if I just open the form without the import, it will not show. Even if I goto the table and see that the record is there with an existing picture.

I wrote some code to try and use a second instance of the table, and force the thing to update (I thought this would be similar to an import), but it does not work, even if I UPDATE the picturebox.

Could someone look at this and tell me what I am doing wrong?

Thanks!
PictureTable.RESET;
PictureTable.SETRANGE(Description, 'Amerace Splash2');

IF PictureTable.FIND('-') THEN BEGIN
// picSplashImage is the PictureBox on the Form, it is bound to
// the currPictures.Picture BLOB field...
currPictures := PictureTable;
CurrForm.picSplashImage.UPDATE();
END ELSE BEGIN
PictureTable.INIT;
PictureTable."No." := '10000';
PictureTable.Description := 'Amerace Splash';
PictureTable.Picture.IMPORT('c:\AmeraceDB\AmeraceSplash.bmp',TRUE);
PictureTable."Last Date Modified" := TODAY;
PictureTable."Picture Type" := 'BMP';
PictureTable.INSERT;
PictureTable.MODIFY;
currPictures := PictureTable;
CurrForm.UPDATE;
END;

If I delete the record from the Picture table and reopen the form it imports and then I can see the image. But everytime after that it opens, it is a blank picturebox.

I delete it, open it again, import it again, it appears.

Thanks in advance for any help you can give!

No one loves you like the one who created you...

Comments

  • ayhan06ayhan06 Member Posts: 210
    Saint-Sage wrote:
    Hello everyone,

    I have a picturebox on a form which I am trying to populate with a high-quality image. I cannot just load it into the bitmap property because it is so large.

    I have a little problem. If I import the file directly into a BLOB table field which I am using as the source for the picturebox, it shows. However, if I just open the form without the import, it will not show. Even if I goto the table and see that the record is there with an existing picture.

    I wrote some code to try and use a second instance of the table, and force the thing to update (I thought this would be similar to an import), but it does not work, even if I UPDATE the picturebox.

    Could someone look at this and tell me what I am doing wrong?

    Thanks!
    PictureTable.RESET;
    PictureTable.SETRANGE(Description, 'Amerace Splash2');
    
    IF PictureTable.FIND('-') THEN BEGIN
    // picSplashImage is the PictureBox on the Form, it is bound to
    // the currPictures.Picture BLOB field...
    currPictures := PictureTable;
    CurrForm.picSplashImage.UPDATE();
    END ELSE BEGIN
    PictureTable.INIT;
    PictureTable."No." := '10000';
    PictureTable.Description := 'Amerace Splash';
    PictureTable.Picture.IMPORT('c:\AmeraceDB\AmeraceSplash.bmp',TRUE);
    PictureTable."Last Date Modified" := TODAY;
    PictureTable."Picture Type" := 'BMP';
    PictureTable.INSERT;
    PictureTable.MODIFY;
    currPictures := PictureTable;
    CurrForm.UPDATE;
    END;
    

    If I delete the record from the Picture table and reopen the form it imports and then I can see the image. But everytime after that it opens, it is a blank picturebox.

    I delete it, open it again, import it again, it appears.

    Thanks in advance for any help you can give!

    you must use calcfields statements to show the blob fields of rec variables in a form.
    PictureTable.RESET;
    PictureTable.SETRANGE(Description, 'Amerace Splash2');
    
    IF PictureTable.FIND('-') THEN BEGIN
    // picSplashImage is the PictureBox on the Form, it is bound to
    // the currPictures.Picture BLOB field...
    currPictures := PictureTable;
    [b]currPictures.calcfields(Picture) [/b]// new line
    CurrForm.picSplashImage.UPDATE();
    

    hope this helps.
  • Saint-SageSaint-Sage Member Posts: 92
    Perfect! It worked!! Thank you!
    \:D/

    No one loves you like the one who created you...
  • ayhan06ayhan06 Member Posts: 210
    you are wellcome.. please put a [SOLVED] to topic name.
Sign In or Register to comment.