-1

I have a TDBImage control. I want to clear/erase/empty through a TButton's click event. i.e., what's displayed on the screen, as opposed to what's in the underlying database which I could accomplish by setting to empty_blob().

It seems the actual image is stored in the Picture property (TPicture) but searching out TPicture has not helped either.

procedure TMyForm.clearPictureButtonClick(Sender: TObject);
begin
  photo.Picture.[WHAT GOES HERE????];
  // or
  // photo.Picture := [WHAT GOES HERE????];
end;

I logical candidates would be something called: clear, erase, blank, empty, etc.

Free, Destroy and DisposeOf clearly deal with releasing the memory for the control back to the OS.

How can I do this?

BIBD
  • 15,107
  • 25
  • 85
  • 137
  • Your question is unclear. Do you want to clear the TDBIMage, or the contents of the field that is connected to the TDBImage? – Ken White Sep 18 '15 at 16:27
  • the part that's displayed on the screen. I can clear the DB at my leisure. – BIBD Sep 18 '15 at 18:21

1 Answers1

4

Clear the Picture property:

photo.Picture := nil;

TDBImage.Picture is a property; assigning to it really calls the Assign method on the image control's internal FPicture field. Thus, the property doesn't actually become nil. Because of that disconnect, you might consider the above code slightly misleading to the naive reader. You can avoid that by typing a little mode:

photo.Picture.Assign(nil);
Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
  • +1 because it works. With some more fighting and digging I think I've come up with a better option for me. – BIBD Sep 18 '15 at 18:53