
DoEvents inside TrueDBGrid RowColChange Event
Yes, Ken, stopping the action was what I wanted, and altho I use static
variable on a regular basis, I didn't even consider it in this instance.
Thanks
I found some notes on the Component1 web site which implied that if the grid
is visible when you populate it, this occurs, so I am going to try setting
its visible property to false at the beginning of the routine and true at
the end of the routine to see if that works. If not, I'll go with the
static variable.
Quote:
> I have zero experience with that grid... but if you want to stop this
> recursion, you can use a Static variable..
> This needs a textbox (Text1)..
> '==============
> Private Sub Text1_Change()
> Static bHereAlready As Boolean
> If Not bHereAlready Then
> bHereAlready = True
> '===your code
> '
> Debug.Print "A"
> Debug.Print "B"
> 'fire change to see it work
> Text1.Text = "12345"
> Debug.Print "C"
> '===end of your code
> bHereAlready = False
> End If
> End Sub
> '==============
> 'This is what shows...
> A
> B
> C
> you can also use a static to limit the number of recursions..
> '==============
> Private Sub Text1_Change()
> Static iRecursCount As Integer
> If iRecursCount <= 1 Then 'runs only twice
> iRecursCount = iRecursCount + 1
> '===your code
> '
> Debug.Print "A"
> Debug.Print "B"
> 'fire change to see it work
> Text1.Text = "12345"
> 'fire change to see it work
> Text1.Text = "54321"
> Debug.Print "C"
> '===end of your code
> iRecursCount = iRecursCount - 1
> End If
> End Sub
> '==============
> 'This is what shows...
> A
> B
> A
> B
> C
> C
> I hope trying to stop/control it was the question<g>
> --
> Ken Halter (VB-MVP)
> Please respond only to the newsgroups so all can benefit.
> > I have some code inside a TrueDBGrid 7.0 dbGrid controls RowColChange
> event.
> > This code segment includes a DoEvents command to allow other Windows
> operations
> > to function.
> > When the code enters this segment and excutes the DoEvents command, the
> > RowColChange event fires a second time, runs thru the entire subroutines
> code
> > (without firing the RowColChange event a third time), then completes the
> rest of
> > the code. What is causing this to happen?
> > The following code causes the subsequent debug window printout
> > public sub grdEvent_RowColChange(.....)
> > Debug.print "A"
> > Debug.print "B"
> > DoEvents
> > Debug.print "C"
> > end sub
> > Immediate window:
> > A
> > B
> > A
> > B
> > C
> > A