Solved

Problem msflexgrid flickering

Posted on 2013-12-23
3
445 Views
Last Modified: 2013-12-24
I am trying to update a 8 row 10 column msflexgrid, but cannot stop the flicker in the cells
setting the autodraw to false then true helps, but does not stop it completely.
How can this be fixed ?
the code
 Sub ResetBoard() 'reset all the cells back to form load(imgCellBG.Picture)
 Dim r As Integer
    Dim c As Integer
    flexCleo.Redraw = False
    DoEvents
    For c = 0 To 9
    For r = 0 To 7
    With flexCleo
    .Col = c
    .Row = r
   
      .CellForeColor = vbWhite '.CellPicture = imgHitUnSelected.Picture
    Set .CellPicture = imgCellBG.Picture
     
    End With
    Next
    Next
    flexCleo.Redraw = True
 End Sub

Open in new window

0
Comment
Question by:isnoend2001
  • 2
3 Comments
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 39738340
Try this. Add the following API declaration at the top of your form

Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long

Open in new window


And then try this
Sub ResetBoard() 'reset all the cells back to form load(imgCellBG.Picture)
 Dim r As Integer
    Dim c As Integer
    'flexCleo.Redraw = False
    LockWindowUpdate flexCleo.hWnd
    DoEvents
    For c = 0 To 9
    For r = 0 To 7
    With flexCleo
    .Col = c
    .Row = r
   
      .CellForeColor = vbWhite '.CellPicture = imgHitUnSelected.Picture
    Set .CellPicture = imgCellBG.Picture
     
    End With
    Next
    Next
    'flexCleo.Redraw = True
    LockWindowUpdate False
 End Sub

Open in new window

0
 

Author Closing Comment

by:isnoend2001
ID: 39738362
Good job
Thanks MartinLiss
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39738371
You're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2013
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question