Synetech
Synetech

Reputation: 9925

How can a list-control be redrawn after changing its alignment style?

I am trying to figure out a way to refresh/update/redraw a list-control after its alignment style (LVS_ALIGNTOP / LVS_ALIGNLEFT) has been changed.

If I change the style from icon/small mode to something else then back again, it works sometimes (only when clicking, programmatically changing doesn’t seem to work even with a delay). Even so, that is pretty kludgey at best (not to mention ugly/flickery) so I would prefer to find a better (more appropriate, more correct?) way.

I tried the list-control’s UpdateWindow, RedrawWindow, Invalidate, RedrawItems, Update… nothing seems to work other than changing the display mode.

Upvotes: 2

Views: 4622

Answers (3)

manatttta
manatttta

Reputation: 3124

Found out what you had to do,

m_listCtrl.Arrange(LVA_DEFAULT);

you might need to change LVA_DEFAULT to your specific requirements. See this

Upvotes: 1

JJ.
JJ.

Reputation: 5475

I've successfully used the CListCtrl.Update() method to solve this issue.

ie:

for (int z=0;z<m_listCtrl.GetItemCount();z++)
{
    m_listCtrl.Update(z);
}

Upvotes: 1

l33t
l33t

Reputation: 19966

RedrawItems(0, GetItemCount() - 1);
UpdateWindow();

Upvotes: 0

Related Questions