|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ListView and ImageList/ImageKeyI try to use an ImageList with a ListView but that don't work. I make a ListView in VirtualMode with LargeIcon view. I put the ImageList in the LargeImageList property. I add a bitmap to the ImageList When i want to see the item "icon" with the imagelist imageindex property that work, but with the imagekey property that don't work At the form load : ListView1.VirtualListSize = 1 In the RetrieveVirtualItem event (use ImageIndex): Dim item As New ListViewItem("test", 0) e.Item = item That work In the RetrieveVirtualItem event (unse ImageKey) : Dim str As String = "1.JPG" Dim item As New ListViewItem("test", str) e.Item = item That don't work ! However ImageList1.Images.ContainsKey(str) = true ! Could you help me ? I have forgotten something ? Thanks (excuse me, i don't speak English very well) Hi Archimed
Your problem is with the way you set the image index <1> Dim str As String = "1.JPG" <2> Dim item As New ListViewItem("test", str) <3> e.Item = item You can remove line <1> and change line <2> to this: <2> Dim item as new ListViewItem("test", 0) The second parameter for the ListViewItem constructor as image index position of the item's icon within the associated ImageList. Hope this helps! Archimed wrote: Show quoteHide quote > Hi, > > I try to use an ImageList with a ListView but that don't work. > > I make a ListView in VirtualMode with LargeIcon view. > I put the ImageList in the LargeImageList property. > > I add a bitmap to the ImageList > > When i want to see the item "icon" with the imagelist imageindex > property that work, but with the imagekey property that don't work > > At the form load : > ListView1.VirtualListSize = 1 > > In the RetrieveVirtualItem event (use ImageIndex): > Dim item As New ListViewItem("test", 0) > e.Item = item > > That work > > In the RetrieveVirtualItem event (unse ImageKey) : > Dim str As String = "1.JPG" > Dim item As New ListViewItem("test", str) > e.Item = item > > That don't work ! However ImageList1.Images.ContainsKey(str) = true ! > > Could you help me ? > I have forgotten something ? > Thanks > > (excuse me, i don't speak English very well) Hi,
Thanks for your reply But i need to use the imagelist with ImageKey The ListViewItem contain however this constructor : .... New(ByVal text As String, ByVal imageKey As String) I don't know why that don't work (ImageList1.Images.ContainsKey(str) = True ! ) glen.ver***@gmail.com wrote: Show quoteHide quote > Hi Archimed > > Your problem is with the way you set the image index > <1> Dim str As String = "1.JPG" > <2> Dim item As New ListViewItem("test", str) > <3> e.Item = item > > You can remove line <1> and change line <2> to this: > <2> Dim item as new ListViewItem("test", 0) > > The second parameter for the ListViewItem constructor as image index > position of the item's icon within the associated ImageList. > > Hope this helps! > > Archimed wrote: > > Hi, > > > > I try to use an ImageList with a ListView but that don't work. > > > > I make a ListView in VirtualMode with LargeIcon view. > > I put the ImageList in the LargeImageList property. > > > > I add a bitmap to the ImageList > > > > When i want to see the item "icon" with the imagelist imageindex > > property that work, but with the imagekey property that don't work > > > > At the form load : > > ListView1.VirtualListSize = 1 > > > > In the RetrieveVirtualItem event (use ImageIndex): > > Dim item As New ListViewItem("test", 0) > > e.Item = item > > > > That work > > > > In the RetrieveVirtualItem event (unse ImageKey) : > > Dim str As String = "1.JPG" > > Dim item As New ListViewItem("test", str) > > e.Item = item > > > > That don't work ! However ImageList1.Images.ContainsKey(str) = true ! > > > > Could you help me ? > > I have forgotten something ? > > Thanks > > > > (excuse me, i don't speak English very well) Hi
Okay, I didn't see the constructor myself (it's good that they've added it)...I am able to get it to work when not using the list view in virtual mode but not while using VirtualMode. Very strange stuff! Why not try the following as a workaround: Dim str As String = "1.JPG" Dim item As New ListViewItem("test", ListView1.LargeImageList.Images.Key(str)) Of course this means you won't be able to change the View type as easily (e.g. from LargeIcon to SmallIcon). Sorry I couldn't help further. Archimed wrote: Show quoteHide quote > Hi, > Thanks for your reply > > But i need to use the imagelist with ImageKey > > The ListViewItem contain however this constructor : > ... New(ByVal text As String, ByVal imageKey As String) > > I don't know why that don't work (ImageList1.Images.ContainsKey(str) = > True ! ) > > > > glen.ver***@gmail.com wrote: > > Hi Archimed > > > > Your problem is with the way you set the image index > > <1> Dim str As String = "1.JPG" > > <2> Dim item As New ListViewItem("test", str) > > <3> e.Item = item > > > > You can remove line <1> and change line <2> to this: > > <2> Dim item as new ListViewItem("test", 0) > > > > The second parameter for the ListViewItem constructor as image index > > position of the item's icon within the associated ImageList. > > > > Hope this helps! > > > > Archimed wrote: > > > Hi, > > > > > > I try to use an ImageList with a ListView but that don't work. > > > > > > I make a ListView in VirtualMode with LargeIcon view. > > > I put the ImageList in the LargeImageList property. > > > > > > I add a bitmap to the ImageList > > > > > > When i want to see the item "icon" with the imagelist imageindex > > > property that work, but with the imagekey property that don't work > > > > > > At the form load : > > > ListView1.VirtualListSize = 1 > > > > > > In the RetrieveVirtualItem event (use ImageIndex): > > > Dim item As New ListViewItem("test", 0) > > > e.Item = item > > > > > > That work > > > > > > In the RetrieveVirtualItem event (unse ImageKey) : > > > Dim str As String = "1.JPG" > > > Dim item As New ListViewItem("test", str) > > > e.Item = item > > > > > > That don't work ! However ImageList1.Images.ContainsKey(str) = true ! > > > > > > Could you help me ? > > > I have forgotten something ? > > > Thanks > > > > > > (excuse me, i don't speak English very well) Thanks a lot ! That's works :)
glen.ver***@gmail.com wrote: Show quoteHide quote > Hi > > Okay, I didn't see the constructor myself (it's good that they've added > it)...I am able to get it to work when not using the list view in > virtual mode but not while using VirtualMode. Very strange stuff! > > Why not try the following as a workaround: > > Dim str As String = "1.JPG" > Dim item As New ListViewItem("test", > ListView1.LargeImageList.Images.Key(str)) > > Of course this means you won't be able to change the View type as > easily (e.g. from LargeIcon to SmallIcon). > > Sorry I couldn't help further. > > > > Archimed wrote: > > Hi, > > Thanks for your reply > > > > But i need to use the imagelist with ImageKey > > > > The ListViewItem contain however this constructor : > > ... New(ByVal text As String, ByVal imageKey As String) > > > > I don't know why that don't work (ImageList1.Images.ContainsKey(str) = > > True ! ) > > > > > > > > glen.ver***@gmail.com wrote: > > > Hi Archimed > > > > > > Your problem is with the way you set the image index > > > <1> Dim str As String = "1.JPG" > > > <2> Dim item As New ListViewItem("test", str) > > > <3> e.Item = item > > > > > > You can remove line <1> and change line <2> to this: > > > <2> Dim item as new ListViewItem("test", 0) > > > > > > The second parameter for the ListViewItem constructor as image index > > > position of the item's icon within the associated ImageList. > > > > > > Hope this helps! > > > > > > Archimed wrote: > > > > Hi, > > > > > > > > I try to use an ImageList with a ListView but that don't work. > > > > > > > > I make a ListView in VirtualMode with LargeIcon view. > > > > I put the ImageList in the LargeImageList property. > > > > > > > > I add a bitmap to the ImageList > > > > > > > > When i want to see the item "icon" with the imagelist imageindex > > > > property that work, but with the imagekey property that don't work > > > > > > > > At the form load : > > > > ListView1.VirtualListSize = 1 > > > > > > > > In the RetrieveVirtualItem event (use ImageIndex): > > > > Dim item As New ListViewItem("test", 0) > > > > e.Item = item > > > > > > > > That work > > > > > > > > In the RetrieveVirtualItem event (unse ImageKey) : > > > > Dim str As String = "1.JPG" > > > > Dim item As New ListViewItem("test", str) > > > > e.Item = item > > > > > > > > That don't work ! However ImageList1.Images.ContainsKey(str) = true ! > > > > > > > > Could you help me ? > > > > I have forgotten something ? > > > > Thanks > > > > > > > > (excuse me, i don't speak English very well)
overides/loads usage
AS400 - Ado.Net from Vb.Net Slow Query Times Can I make my Form visible during a debug session? Database Connection Problem. Please Help Problems using Me.Scale in Framework 2.0 enforce event calling on inherited classes Is this a bug: 2.2 - 0.4 = 1.8 but 1.2 - 0.4 = 0.8000001 ? Multiple executescalar() Commenting Out Controls In HTML View Convert Array of Objects to Generics List? |
|||||||||||||||||||||||