|
-
Jul 15th, 2006, 05:06 AM
#1
Thread Starter
Addicted Member
[2005]ListBox Background Image???
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
Last edited by sweet_dreams; Jul 15th, 2006 at 05:34 AM.
using VB 2010 .NET Framework 4.0; MS Office 2010; SQL Server 2008 R2 Express Edition | Remember to mark resolved threads and rate useful posts. 
-
Jul 15th, 2006, 06:12 AM
#2
Re: [2005]ListBox Background Image???
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'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Sep 30th, 2006, 10:52 AM
#3
Junior Member
Re: [2005]ListBox Background Image???
 Originally Posted by ComputerJy
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 ?
-
Sep 30th, 2006, 01:18 PM
#4
Re: [2005]ListBox Background Image???
Just put that code in a file, save it. And instead of declaring
VB Code:
Friend WithEvents ListBox1 As New ListBox
use
VB Code:
Friend WithEvents ListBox1 As New MyListBox
And use ListBox1.BackgroundImage to set the Image property
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|