Recent

Author Topic: [SOLVED] Moving from(row-x-Blob) to(row-Y-Blob) doesn't trigger OnColEnter event  (Read 3153 times)

Elmug

  • Hero Member
  • *****
  • Posts: 849
Hi everyone,

Windows-7 SQLite3

This is happening here:

I have a table with colums of Integer, String, Memo, and one Column named Pic that holds Blob (pictures) data.

I have for the DBGRid a small procedure triggered by DBGrid1ColEnter. The procedure clears the image in a DBImage box first thing, in the understanding that that image would not belong to the next row clicked, and the image is to show only when its Blob cell is cliked, or current.

The defined SQL is SELECT * FROM TABLExyz, the only table in the db.

The app starts showing the data but no image, as expected. The words Blob show in the cells with images, as expected, too. So this is correct up to here.

The DBImage box is to get the Blob Image as soon as its Blob field is clicked by code in the OnColChange of the DBGrid.

So, if I click on row-1's Blob, its image does show in the DBImage box correctly.

If then I click on Any other column, the image in DBImage clears, EXCEPT if I click on row2's Blob cell.

When I have just clicked Blob of row1, and its image shows, if I click next into row2's Blob box, the previous image REMAINS, as if OnColChange is not triggered.

The only way that the image in row2 shows, is if when being in row1's Blob, I next hit any column that is not a Blob, then I click row2's Blob, and its image shows.

So, I can not go clicking from Blob to Blob and see the images change in correspondance to the current row. This is as if going from Blob to Blob, is  NOT understood by the internals as a Column Change, and this seems to me like a bug.

If I place CURSOR on Blob of row1 and use the navigator to go up and or down in the Blob column, again, no change of image takes place, showing only the first blob colunm where the cursor enters.

Cells that are NOT Blob type, YES, they respond to the OnColChange code, by clearing the DBImage image. Cells other than Blob have no problem showing what they contain.

Any explanations, or rationale, corrections, or confirmation of being a bug, of this unexpected and undesired behavior, as explained?

I really wish this to work correctly.

P.S. The very first line of the OnColChange event of DBGrid1 is:
DBImage1.Picture.Graphic := nil; {clears the previous picture}

Thanks.
« Last Edit: July 22, 2012, 12:06:52 pm by Elmug »

Knipfty

  • Full Member
  • ***
  • Posts: 230
Elmug,

Where are you eventually going with this app?  Or is it right now that you are experimenting to see what happens?

The OnColChange and OnRowChange events are triggered when those items change.  Once you are in a column, changing the row will not trigger the OnColChange event.  So you need to be a little smarter about your event handling.  Maybe you need them both to point to the same event handler.

If you need to display the picture only when they click in a picture cell, then you need to check that you are in a picture cell.

I hope that helps,

Knipfty
32-bit Lazarus 1.0 FPC 2.6.0, 64-bit Win 7, Advantage DB 10.10

Elmug

  • Hero Member
  • *****
  • Posts: 849
Elmug,

Where are you eventually going with this app?  Or is it right now that you are experimenting to see what happens?

The OnColChange and OnRowChange events are triggered when those items change.  Once you are in a column, changing the row will not trigger the OnColChange event.  So you need to be a little smarter about your event handling.  Maybe you need them both to point to the same event handler.

If you need to display the picture only when they click in a picture cell, then you need to check that you are in a picture cell.

I hope that helps,

Knipfty

No, sorrry.

It does not help.

The OnColEvents DO NOT trigger on Column Change WHEN the field is type Blob, just as stated.

But thanks for trying to help.

Elmug

  • Hero Member
  • *****
  • Posts: 849
Solved: By putting intended code in SQLQuery1 AfterScroll event, AND copypasting the same code lines to DBGrid's OnCellClick.
« Last Edit: July 22, 2012, 12:09:37 pm by Elmug »