Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I wrote a MFC application program.I used some ListControl controls and some radio buttons in the dialog.I would like to realize real-time-update data with ListControl when clicked the single radiobutton triggering the corresponding events.

Firstly,when the dialog initialized,inserting data into the ListControl and showing the dialog.

Secondly,when I clicked the one radiobutton among these.The first step was to delete the all columns and all items in the ListControl.The second step was to insert my neccessary data into the ListControl.By the way,I used the same variable relative to the ListControl ID.

Notice:The data was changed by time!

Finally I found that the ListControl window appeared the fast flash and felt so bad.
So is there some good ways to solve this problem?And can you suggest some good or advanced advice to me?Thanks a lot!

What I have tried:

The ways I've tried were not valid...
Posted
Updated 27-Jul-17 20:58pm

1 solution

The simplest solution is disabling drawing when the list is updated.
C++
m_ListCtrl.SetRedraw(0);

// Update list here

m_ListCtrl.SetRedraw(1);
// Invalidate entire control
// May also use InvalidateRect() for a specific area
m_ListCtrl.Invalidate();
// Force redrawing
m_ListCtrl.UpdateWindow();

If possible you should only change portions of the list instead of replacing the complete content. Also there is often no need to remove the columns when those will not change.

[EDIT]
You may also set the LVS_EX_DOUBLEBUFFER Extended List-View Styles (Windows)[^] to reduce flickering.
[/EDIT]
 
Share this answer
 
v2
Comments
Mark Danniel 28-Jul-17 3:54am    
Thanks.I'll have a try.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900