Hi all,
Is it possible to set image as a ListBoxs background??? ListBox doesn't have BackGroundImage property, so is it possible to be done?
please help,
sweet_dreams
Printable View
Hi all,
Is it possible to set image as a ListBoxs background??? ListBox doesn't have BackGroundImage property, so is it possible to be done?
please help,
sweet_dreams
you have to make up your own ListBox:
VB Code:
Public Class MyListBox Inherits ListBox Private BGImage As Image Public Overrides Property BackgroundImage() As Image Get Return BGImage End Get Set(ByVal Value As Image) BGImage = Value End Set End Property Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) Dim g As Graphics = e.Graphics g.DrawImage(BGImage, New PointF(0, 0)) End Sub Protected Overrides Sub Refre****em(ByVal index As Integer) End Sub Protected Overrides Sub SetItemsCore(ByVal items As System.Collections.IList) End Sub End Class
EDIT: The stars refer to "Refresh Item"
I am not very proficient in subclassing and / or building custom controls. Can you pl elaborate how to use the above code ?Quote:
Originally Posted by ComputerJy
Just put that code in a file, save it. And instead of declaringuseVB Code:
Friend WithEvents ListBox1 As New ListBoxAnd use ListBox1.BackgroundImage to set the Image propertyVB Code:
Friend WithEvents ListBox1 As New MyListBox