ListView ImageList Problem

J

James Zhuo

Hi

I've been encountering a rather weird problem when using
listview.

I am using visual studio 2002 with framework 1.1. What i
am trying to do is to display an appropriate icon as i
load some data into a listview. The icon comes from a
imagelist called ImageListPrivilege.

The full implementation is as follows. This implemenation
works fine at first, but after a few compilation the icons
stops diplaying even tho that the listview is still
populated with the correct data. If i replace the
listview, then it works again, but after a few more
compilation it starts doing the same thing. I have
absolutely no idea why this is happening, any
suggestions?? I am thinking it could be something with how
i set the listview properties. So i've attached my
listview property settings below the code.

Any help would be greatly appreciated.

CODE:
Dim _cmd_depot As New OracleCommand()
_cmd_depot.Connection = _OraConnection
_cmd_depot.CommandType = CommandType.Text
_cmd_depot.CommandText = "select id,
depot_name from PAYROLL.DEPOTS"
Dim _rdr_depot As OracleDataReader =
_cmd_depot.ExecuteReader
While _rdr_depot.Read()
Dim _cmd_privilege As New OracleCommand()
_cmd_depot.Connection = _OraConnection
_cmd_privilege.Connection = _OraConnection
_cmd_privilege.CommandType =
CommandType.Text

_cmd_privilege.Parameters.Add("depotid",
OracleDbType.Int16, _rdr_depot!id,
ParameterDirection.Input)
_cmd_privilege.CommandText = "select
table_name from user_tab_privs " & _
"where
table_name in
('ROSTERS_RO_'||:depotid, 'ROSTERS_RW_'||:depotid) " & _
"and grantee =
(select user from dual) and privilege = 'EXECUTE' "
Dim _rdr_privilege As OracleDataReader =
_cmd_privilege.ExecuteReader()
Dim _item As New ListViewItem()
_item.Text = _rdr_depot!depot_name
Dim _depot_info As New DepotInfo()
_depot_info.DepotID = _rdr_depot!id
_depot_info.DepotName = _rdr_depot!
depot_name
While _rdr_privilege.Read()
If (_rdr_privilege!table_name
= "ROSTERS_RW_" & _rdr_depot!id) Then
_depot_info.DBPackage
= "ROSTERS_RW_" & _rdr_depot!id
_item.ImageIndex = 1
Else
_depot_info.DBPackage
= "ROSTERS_RO_" & _rdr_depot!id
_item.ImageIndex = 0
End If
End While
_item.Tag = _depot_info
lvwDepots.Items.Add(_item)
End While


LISTVIEW PROPERTIES:
'
'lvwDepots
'
Me.lvwDepots.Dock =
System.Windows.Forms.DockStyle.Fill
Me.lvwDepots.FullRowSelect = True
Me.lvwDepots.MultiSelect = False
Me.lvwDepots.Name = "lvwDepots"
Me.lvwDepots.Size = New System.Drawing.Size(156,
666)
Me.lvwDepots.SmallImageList = Me.ImageListPrivilege
Me.lvwDepots.TabIndex = 0
Me.lvwDepots.View = System.Windows.Forms.View.List
 
J

James Zhuo

Hi again

Another addition that may help giving clue as to what the
problem is.

It always seem to stop displaying the icon whenever I add
some new code which has nothing to do with the listview.

You would also notice that the listView view property
is "List", If I change it to "Detail" view and adding a
column to the columns collection, the listview won't even
display the text that is associated with each item even
tho that the listview is populated with item. This is too
weird. I have used listview plenty of times before and i
have never came across this problem, The only thing that
is different to every other time is that i'd never
actually use try to display icon in the listview, but this
doesn't explain why a populated list won't display its
associated text.

I am scratching my head out. :(

Cheers
James
 

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