
Listview problem - Setting the current line to display
I am having trouble making sure that the line in the listview I want to make
see is visible. I have been using .EnsureVisible to try and get the line I
want to be displayed. However if there is more than one screen of data and
I want the last item to be displayed i.e. lastedit=total_prcess, the last
item appears just below the bottom of the visible part of the listview.
Is there a way of forcing the complete line to be visible?
I have put the code for comments below.
--
Best regards
Andy Stewartson
Mechanical Engineer Team Leader
Mechanical Engineering Design Services
Avionics Group
BAE SYSTEMS Avionics Ltd
Rochester, ME1 2XX
Tel: +44 1634 204562
Fax: +44 1634 816360
Dim si As ListSubItem
Dim li As ListItem
'
' update display
'
For i = 1 To total_process
'
' set colour
'
fore_colour = BLACK
'
' if process less than 6sigma then make red and count
'
If scorecard(i).hitter > 0 Then fore_colour = RED
'
' if excluded then show as green
'
If scorecard(i).exclude > 0 Then fore_colour = GREEN
'
' last change item show in blue
'
If i = lastedit Then fore_colour = BLUE
'
' add item number
'
Set li = Form1.ListView1.ListItems.Add(Text:=Format(i,
items_format))
li.ForeColor = fore_colour
'
' add operation
'
Set si = li.ListSubItems.Add(Text:=default_operations(process_id,
operation_id))
si.ForeColor = fore_colour
'
' add grade
'
msg = default_grades(grade_id)
Set si = li.ListSubItems.Add(Text:=msg)
si.ForeColor = fore_colour
'
' add number off
'
Set si = li.ListSubItems.Add(Text:=scorecard(i).ofd)
si.ForeColor = fore_colour
'
' make sure last change is visible, if delete has been user then lastedit
will be negative
'
If i = Abs(lastedit) Then li.EnsureVisible
'
Next