H
Hany Metry
Guest
Hi,
Invalid operation exception was unhandeled due to empty a listview or any code in listview after adding code of zoom.
as show in the two images below.
Can any one assist.
I have not problem before but after adding the below code in form32 the problem happened.
Private Sub PictureBox2_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox2.Paint
With e.Graphics
.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
.ScaleTransform(Sx, Sx)
.DrawImage(bm, 0, 0)
If resizing Then
.DrawRectangle(RSpen, resizerect)
End If
End With
End If
End Sub
Dim sx, zoomfactor As Single
Dim resizing As Boolean = False
Dim resizerect As New Rectangle
Dim RSpen As New Pen(Color.Black)
Dim bm As New Bitmap(PictureBox2.Width, PictureBox2.Height)
Dim currMP As Point
Private Sub Form32Irregular_byCoordinates_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox2.Refresh()
Sx = 1 : zoomfactor = 2.0
With RSpen
.Width = 4.0F
.DashCap = Drawing2D.DashCap.Round
.DashPattern = New Single() {4.0F, 2.0F}
End With
End Sub
Private Sub ZoomToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ZoomToolStripMenuItem.Click
resizerect = Rectangle.Round(bm.GetBounds(GraphicsUnit.Pixel))
resizing = True
currMP = PointToClient(MousePosition)
PictureBox2.Invalidate()
End Sub
Private Sub ResetToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ResetToolStripMenuItem.Click
sx = 1
resizing = False
PictureBox2.Invalidate()
End Sub
Private Sub picturebox2_MouseClick(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseClick
resizing = False
PictureBox2.Invalidate()
End Sub
Private Sub picturebox2_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseMove
If resizing Then
If e.Location.X > currMP.X Then
sx += zoomfactor / 20
End If
If e.Location.X < currMP.X Then
sx -= zoomfactor / 20
End If
currMP = e.Location
PictureBox2.Invalidate()
End If
End Sub
Kind Regards,
Hany Metry
Continue reading...
Invalid operation exception was unhandeled due to empty a listview or any code in listview after adding code of zoom.
as show in the two images below.
Can any one assist.
I have not problem before but after adding the below code in form32 the problem happened.
Private Sub PictureBox2_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox2.Paint
With e.Graphics
.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
.ScaleTransform(Sx, Sx)
.DrawImage(bm, 0, 0)
If resizing Then
.DrawRectangle(RSpen, resizerect)
End If
End With
End If
End Sub
Dim sx, zoomfactor As Single
Dim resizing As Boolean = False
Dim resizerect As New Rectangle
Dim RSpen As New Pen(Color.Black)
Dim bm As New Bitmap(PictureBox2.Width, PictureBox2.Height)
Dim currMP As Point
Private Sub Form32Irregular_byCoordinates_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox2.Refresh()
Sx = 1 : zoomfactor = 2.0
With RSpen
.Width = 4.0F
.DashCap = Drawing2D.DashCap.Round
.DashPattern = New Single() {4.0F, 2.0F}
End With
End Sub
Private Sub ZoomToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ZoomToolStripMenuItem.Click
resizerect = Rectangle.Round(bm.GetBounds(GraphicsUnit.Pixel))
resizing = True
currMP = PointToClient(MousePosition)
PictureBox2.Invalidate()
End Sub
Private Sub ResetToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ResetToolStripMenuItem.Click
sx = 1
resizing = False
PictureBox2.Invalidate()
End Sub
Private Sub picturebox2_MouseClick(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseClick
resizing = False
PictureBox2.Invalidate()
End Sub
Private Sub picturebox2_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseMove
If resizing Then
If e.Location.X > currMP.X Then
sx += zoomfactor / 20
End If
If e.Location.X < currMP.X Then
sx -= zoomfactor / 20
End If
currMP = e.Location
PictureBox2.Invalidate()
End If
End Sub
Kind Regards,
Hany Metry
Continue reading...