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
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