Bodmoor
2017-01-03T10:19:33Z
Hello,

I've implemented the sample in the help to draw a red dot in all fields on the grid. When I click anywhere else in the grid, the custom content appears again, then immediately disappears again and stays gone.

Is this behaviour by design or am I doing something wrong, or maybe not doing something I do need to do to ensure the custom drawn content is always displayed?

Specifically, I have a grid that will open a dialog when clicked. I want to show a 'browse' button, and when that cell is clicked, the button needs to stay there.

Kind Regards,
Paul
Igor/10Tec
2017-01-03T16:42:13Z
Can you send us a sample to reproduce the issue?
Bodmoor
2017-01-04T08:38:01Z
Hi,

In the simplest manner possible, the issue does not reproduce when I isolate it. I'll need to do some additional research, to see if it is related to screenupdating issues. (beginupdate)

Kind regards,
Paul
Bodmoor
2017-01-04T12:54:16Z
Is it possible that the AfterCellContentsDraw event does not fire if I called BeginUpdate, until I call EndUpdate?

EDIT:
I've added an example form that shows the erroneous behaviour.

  Test.zip (3kb) downloaded 41 time(s).

use the form like:

DoCmd.OpenForm "Test"
Form_Test.init

then click around in the cells.
Igor/10Tec
2017-01-05T07:33:07Z
I imported your text definition of the form using Application.LoadFromText, but it was not enough. As I see, you are using some global vars as gdGrid not defined in the module, we have the Init sub never called, etc.

Can you send us a full sample to reproduce the issue?

And what is the purpose of having the following event handler?

Private Sub iGrid_Click(ByVal lRowIfAny As Long, ByVal lColIfAny As Long)
    gdGrid.BeginUpdate
    
    gdGrid.EndUpdate
End Sub


BTW, it's an interesting thought that AfterCellContentsDraw should not be fired if redrawing is turned off. Do you think it may help in your case?
Bodmoor
2017-01-05T07:56:24Z
I called the init sub manually:

Docmd.OpenForm "Test"
Form_Test.Init

But I attached a accdb now that works better, just open the form.

  test.zip (28kb) downloaded 48 time(s).

And the eventhandler exposes the problem where the custom content vanishes. Comment those two lines and the content does not disappear, but like this, when you click on cells in the grid, the red dots seem random.

I think the draw events should be fired, even though redrawing is turned off. Because redrawing is linked to what you see on the screen, not what is actually happening in the cell.
Igor/10Tec
2017-01-06T12:58:35Z
Yes, when I comment out those BeginUpdate/EndUpdate, I see the effect you are talking about. But in this case we are just trying to emulate it. Can you show us when this problem really occurs in a real-world database?
Bodmoor
2017-01-09T08:09:30Z
that's a bit hard to do. Our database is an application that needs certain external libraries and an external database. It won't work without those.

The effect is emulated, but emulated very well. It matches the real effect perfectly. Is there another way that I can provide more info? Like a video taken of the effect perhaps?
Igor/10Tec
2017-01-09T10:58:58Z
You emulated the effect, but I need to reproduce it in a real situation to fix it.

Try to create a new database with one form and copy the code from the original database until you reproduce the issue.
Igor/10Tec
2017-01-10T11:30:16Z
I'm still thinking about this problem. Some questions:

1) Is your dialog displayed as a modal form?

2) Do you display it from the Click event? Have you tried another event like MouseDown or MouseUp?

The problem may be related to some specific Windows message processing in MS Access or something like that.
Bodmoor
2017-01-10T11:39:23Z
Hi,

There are forms that are displayed modally, but usually they're not modal. In the specific example, the grid is loaded using a method call from outside the form, that is how we use it as well.

1. A user clicks on a button on another form (menu)
2. a new form is opened
3. the grid receives data, usually through a recordset
4. the form is displayed (either as the main content, but the menu is still available or as a modal window (a search window))
5. initially the custom content is drawn.
6. a user clicks in the grid
7. an event is fired, that might affect the contents. Therefore, somewhere along the line the beginupdate call is used on the grid
8. assumption: starting from beginupdate, until endupdate is called, all instances of aftercellcustomdraw are ignored.
9. some or all of the custom content in the cell disappears.

The grid appears when loading the form, but the beginupdate may be called from a number of events, inclusing mouseevents, clickevents, timerevents... I think most of those are used in the application a a whole.

I still need some more time to create a stripped database containing something more of a real-word example, though I still think the previous example is quite thorough already and close to reality.

Thanks for your thoughts thus far,
paul
Igor/10Tec
2017-01-12T11:57:45Z
As I explained, all drawing operations including the AfterCellContentsDraw event must be ignored if updates are off after BeginUpdate. However, when you call the last EndUpdate and the grid must be updated, all cells in the grid should be redrawn and sure, all related AfterCellContentsDraw event handlers should be executed. That's strange if this does not happen in your case...