imagelist problem with treeview and listview

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I've this code:

Dim ImageList1 As New ImageList
ImageList1.Images.Add(Image.FromFile("..\images\statusOK.bmp"))
ImageList1.Images.Add(Image.FromFile("..\images\statusKO.bmp"))
TV.ImageList = ImageList1
Dim rootNode As New TreeNode("Test", 0, 1)
rootNode.Text = "TEST"
TV.Nodes.Add(rootNode)

this works fine in win2003/win2000, but in XP, i cannot see the images in
the treeview. it occurs also in listviews

vb.net/fw1.1/ visualstyle enable

thanks for your help
 
I know it's not much help, but that code works fine for me in XPSP2, VB.net,
fw 1.1, with or without visual styles.

Here's the exact code I used to test:

\\\
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) _
Handles MyBase.Load
CreateBmps()
Dim ImageList1 As New ImageList
ImageList1.Images.Add(Image.FromFile("..\images\statusOK.bmp"))
ImageList1.Images.Add(Image.FromFile("..\images\statusKO.bmp"))
TreeView1.ImageList = ImageList1
Dim rootNode As New TreeNode("Test", 0, 1)
TreeView1.Nodes.Add(rootNode)
Dim childNode As New TreeNode("Test Child", 0, 1)
rootNode.Nodes.Add(childNode)
End Sub

Private Sub CreateBmps()
If Not (IO.File.Exists("..\images\statusOK.bmp")) Then
If Not (IO.Directory.Exists("..\images\")) Then
IO.Directory.CreateDirectory("..\images\")
End If
Dim bmp As New Bitmap(16, 16)
Dim g As Graphics = Graphics.FromImage(bmp)
g.Clear(Color.Green)
bmp.Save("..\images\statusOK.bmp", Imaging.ImageFormat.Bmp)
g.Clear(Color.Red)
bmp.Save("..\images\statusKO.bmp", Imaging.ImageFormat.Bmp)
g.Dispose()
bmp.Dispose()
Else
MessageBox.Show("Done already")
End If
End Sub
///
 
Back
Top