coolpjmartin
Member
- Joined
- Aug 8, 2006
- Messages
- 9
- Programming Experience
- Beginner
Hi
Can anybody help with the problem I am getting with refreshing of the thumbnail border when scrolling?
What I wanted to do is place a number of pictureboxes of a panel which is contained on a form and has a border around the picturebox, this is fine I have managed to do this.
If I place more picturebox controls (with border) on the panel, so they scroll of the bottom, then when I use the standard scrollbar for the panel the picturebox border does not redraw correctly.
Can anybody please advice how to overcome this problem?
Thanks
I have created a test project to show you the problem.
Add a Panel to a windows form, and set the autoscroll property to “True”
Set Pics(iLoop).ImageLocation = "C:\IMG_0195.JPG.jpg" to point your own picture, it’s not essential as you can see the problem without the image set.
Public Class Form1
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Pics As PictureboxThumb.PictureboxThumb()
Pics = New PictureboxThumb.PictureboxThumb(30) {}
Dim iLoop As Integer = 0
For iLoop = 0 To (30)
Pics(iLoop) = New PictureboxThumb.PictureboxThumb
Pics(iLoop).Size = New System.Drawing.Size(90, 90)
Pics(iLoop).SizeMode = PictureBoxSizeMode.Zoom
Pics(iLoop).Location = New System.Drawing.Point(30, 100 * iLoop)
Pics(iLoop).BorderColorA = Color.DarkBlue
Pics(iLoop).BorderWidthA = 3
Pics(iLoop).ImageLocation = "C:\IMG_0195.JPG.jpg"
Panel1.Controls.Add(Pics(iLoop))
Next
End Sub
End Class
Create a new class called “PictureboxThumb”
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Namespace PictureboxThumb
Public Class PictureboxThumb
Inherits PictureBox
#Region "fields-PictureBox"
Private valPicture As Image
Private valBorderWidth As Integer = 1
Private valBorderColor As Color = Color.LightBlue
'Private mPictureBox As PictureBox
#End Region
#Region "properties"
Public Property BorderWidthA() As Integer
Get
Return valBorderWidth
End Get
Set(ByVal Value As Integer)
valBorderWidth = Value
End Set
End Property
Public Property BorderColorA() As Color
Get
Return valBorderColor
End Get
Set(ByVal Value As Color)
valBorderColor = Value
End Set
End Property
#End Region
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
' this has a redraw problem
ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, BorderColorA, 3)
End Sub 'OnPaint
Private Sub InitializeComponent()
CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'PictureboxThumb
'
Me.BackColor = System.Drawing.Color.Maroon
CType(Me, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
End Class
End Namespace
Can anybody help with the problem I am getting with refreshing of the thumbnail border when scrolling?
What I wanted to do is place a number of pictureboxes of a panel which is contained on a form and has a border around the picturebox, this is fine I have managed to do this.
If I place more picturebox controls (with border) on the panel, so they scroll of the bottom, then when I use the standard scrollbar for the panel the picturebox border does not redraw correctly.
Can anybody please advice how to overcome this problem?
Thanks
I have created a test project to show you the problem.
Add a Panel to a windows form, and set the autoscroll property to “True”
Set Pics(iLoop).ImageLocation = "C:\IMG_0195.JPG.jpg" to point your own picture, it’s not essential as you can see the problem without the image set.
Public Class Form1
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Pics As PictureboxThumb.PictureboxThumb()
Pics = New PictureboxThumb.PictureboxThumb(30) {}
Dim iLoop As Integer = 0
For iLoop = 0 To (30)
Pics(iLoop) = New PictureboxThumb.PictureboxThumb
Pics(iLoop).Size = New System.Drawing.Size(90, 90)
Pics(iLoop).SizeMode = PictureBoxSizeMode.Zoom
Pics(iLoop).Location = New System.Drawing.Point(30, 100 * iLoop)
Pics(iLoop).BorderColorA = Color.DarkBlue
Pics(iLoop).BorderWidthA = 3
Pics(iLoop).ImageLocation = "C:\IMG_0195.JPG.jpg"
Panel1.Controls.Add(Pics(iLoop))
Next
End Sub
End Class
Create a new class called “PictureboxThumb”
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Namespace PictureboxThumb
Public Class PictureboxThumb
Inherits PictureBox
#Region "fields-PictureBox"
Private valPicture As Image
Private valBorderWidth As Integer = 1
Private valBorderColor As Color = Color.LightBlue
'Private mPictureBox As PictureBox
#End Region
#Region "properties"
Public Property BorderWidthA() As Integer
Get
Return valBorderWidth
End Get
Set(ByVal Value As Integer)
valBorderWidth = Value
End Set
End Property
Public Property BorderColorA() As Color
Get
Return valBorderColor
End Get
Set(ByVal Value As Color)
valBorderColor = Value
End Set
End Property
#End Region
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
' this has a redraw problem
ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, BorderColorA, 3)
End Sub 'OnPaint
Private Sub InitializeComponent()
CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'PictureboxThumb
'
Me.BackColor = System.Drawing.Color.Maroon
CType(Me, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
End Class
End Namespace