Unanswered: Problems with ListView control(s) in TabControl
Hi all, this is an answer with a question!
Populating a ListView control in report format on a TabControl page can cause the following display problems:
1. ListView control position incorrect - toggling tab page results in control repaint and position is corrected.
2. ListView Checkboxes disappear when toggling tab pages.
3. ListView SelectedItem scroll position changes when toggling tab pages - ListView is repainted so that top of scrolling list is visible.
Many forum answers recommend forcing ListView position in code to cure problem 1 and other display problems (not mentioned here) could be sorted by removing the ListView controls from the TabControl and use the TabControl.Change event to set the visible property. However, problems 2 & 3 still persist.
My personal solution has been to move the ListView control(s) to the form detail section and use TabControl.Change event to set the HEIGHT property of the ListView control. For example if you have 2 ListView controls and you want ListView1 revealed when page 1 is toggled and ListView2 revealed when page 2 is toggled then:
Private Sub tabListView_Change()
On Error GoTo Err_tabListView_Change
Static ListView1Height As Long
Static ListView2Height As Long
'Work around for display bug.
If ListViewHeight = 0 Then
ListView1Height = ListView1.Height
ListView2Height = ListView2.Height
Select Case tabListView.Value
ListView1.Height = ListView1Height
ListView2.Height = 1
ListView1.Height = 1
ListView2.Height = ListView2Height
MsgBox "tabListView_Change Error: " & Err.Number & ": " & Err.Description
Has anyone else any other ways to tackle this problem?