Problems with ListView control(s) in TabControl

  • Thread starter IanOxon via AccessMonster.com
  • Start date
I

IanOxon via AccessMonster.com

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
End If
Select Case tabListView.Value
Case 0
ListView1.Height = ListView1Height
ListView2.Height = 1
Case 1
ListView1.Height = 1
ListView2.Height = ListView2Height
End Select

Exit_tabListView_Change:
Exit Sub

Err_tabListView_Change:
MsgBox "tabListView_Change Error: " & Err.Number & ": " & Err.Description
Resume Exit_tabListView_Change
End Sub

Has anyone else any other ways to tackle this problem?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top