|
-
Oct 29th, 2021, 09:02 AM
#1
Thread Starter
Lively Member
[RESOLVED] autofit image in multi picturebox and then clicked pop up full size image in VB.NET
Dear All master,
please the solution I want the best autofit image in multi picturebox and then I clicked the picturebox then a full-size pop-up image appeared according to the original image size
Can pop up be done with the mouse and keyboard keys?.
for information i use visual studio 2010.
Thanks
roy88
Code:
Public Class Form1
Dim Path As String = "C:\Users\Administrator\Desktop\DBF"
Dim Pathimage As String = "C:\Users\Administrator\Desktop\CATALOG"
Dim cn = "provider=Microsoft.Jet.OLEDB.4.0; data source=" & Path & "; Extended Properties=dBase IV"
Private Sub PopulateDataGridView()
Try
Dim dt = New DataTable()
Dim query = "select ITM,ITC,QOH,PRS,FILENAME1,FILENAME2,FILENAME3,FILENAME4 FROM ITEM"
Using adapter As New OleDbDataAdapter(query, cn.ToString)
adapter.Fill(dt)
End Using
Me.DataGridView1.DataSource = dt
For x as integer = 4 to 7
Me.DataGridView1.Columns(x).Visible = False
Next
exPictureBox1.PrePath = Pathimage & "\"
exPictureBox2.PrePath = Pathimage & "\"
exPictureBox3.PrePath = Pathimage & "\"
exPictureBox4.PrePath = Pathimage & "\"
exPictureBox1.DataBindings.Add("FileName", dt, "FILENAME1")
exPictureBox2.DataBindings.Add("FileName", dt, "FILENAME2")
exPictureBox3.DataBindings.Add("FileName", dt, "FILENAME3")
exPictureBox4.DataBindings.Add("FileName", dt, "FILENAME4")
Catch myerror As OleDbException
MessageBox.Show("Error: " & myerror.Message)
Finally
End Try
End Sub
End Class
-
Oct 29th, 2021, 03:16 PM
#2
Re: autofit image in multi picturebox and then clicked pop up full size image in VB.N
So you’re looking for thumbnail images that can be viewed at full size. What if full size is unreasonably large? Wouldn’t it be better to resize them all to a uniform size, whatever the original size is?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 29th, 2021, 05:06 PM
#3
Re: autofit image in multi picturebox and then clicked pop up full size image in VB.N
Seems simple enough.
If you set the picturebox's Sizemode to Zoom the image will be scaled to fit proportionally within the picturebox, so that can give you your samesized thumbnail type images.
If you select one to show at full size, then just set the sizemode of a "fullsize" picturebox to AutoSize, and the picturebox will be sized to fit the image, so you see the full size image.
But as Paul says, perhaps what you really would want is the option to scale in both directions, so use Zoom mode in all the pictureboxes, and just use a large picturebox to show a large size version of the smaller pictureboxes.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Oct 30th, 2021, 08:45 AM
#4
Thread Starter
Lively Member
Re: autofit image in multi picturebox and then clicked pop up full size image in VB.N
 Originally Posted by .paul.
So youÂ’re looking for thumbnail images that can be viewed at full size. What if full size is unreasonably large? WouldnÂ’t it be better to resize them all to a uniform size, whatever the original size is?
Dear Mr. .paul.
thanks for your reply. I agree with your suggestion to resize everything to a uniform size in the picture box and I want to click the picturebox then the picture appears in the preview panel.
how to code solution?
Thanks
roy88
-
Oct 30th, 2021, 10:10 AM
#5
Re: autofit image in multi picturebox and then clicked pop up full size image in VB.N
Set the exPictureBox1-4 SizeMode to Zoom (in the designer) as passel told you, then add a larger standard PictureBox set Name to largerPictureBox and set SizeMode to Zoom.
Then...
Code:
Private Sub exPictureBoxs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exPictureBox1.Click, exPictureBox2.Click, exPictureBox3.Click, exPictureBox4.Click
largerPictureBox.Image = DirectCast(sender, exPictureBox).Image
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 30th, 2021, 10:29 AM
#6
Thread Starter
Lively Member
Re: autofit image in multi picturebox and then clicked pop up full size image in VB.N
 Originally Posted by .paul.
Set the exPictureBox1-4 SizeMode to Zoom (in the designer) as passel told you, then add a larger standard PictureBox set Name to largerPictureBox and set SizeMode to Zoom.
Then...
Code:
Private Sub exPictureBoxs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exPictureBox1.Click, exPictureBox2.Click, exPictureBox3.Click, exPictureBox4.Click
largerPictureBox.Image = DirectCast(sender, exPictureBox).Image
End Sub
Dear Mr. .paul.
thanks for your reply.
I tried according to your suggestion and the code runs perfectly and I set largerPictureBox to normal but the problem is that if I make a selection in the row datagridview exlargepicturebox still exists if I click on the picturebox then the exlargepicturebox changes with the image. So can the exlargepicturebox be blank when switching row selection in datagridview?
Thanks
roy88
-
Oct 30th, 2021, 11:20 AM
#7
Re: autofit image in multi picturebox and then clicked pop up full size image in VB.N
Add this, at Form level...
Code:
Private WithEvents dt As New DataTable
Then instead of...
Code:
Dim dt As New DataTable
Use...
And add this Handler...
Code:
Private Sub dt_RowChanging(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles dt.RowChanging
largerPictureBox.Image = Nothing
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 30th, 2021, 12:14 PM
#8
Thread Starter
Lively Member
Re: autofit image in multi picturebox and then clicked pop up full size image in VB.N
 Originally Posted by .paul.
Add this, at Form level...
Code:
Private WithEvents dt As New DataTable
Then instead of...
Code:
Dim dt As New DataTable
Use...
And add this Handler...
Code:
Private Sub dt_RowChanging(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles dt.RowChanging
largerPictureBox.Image = Nothing
End Sub
Code:
Private WithEvents dt As New DataTable
Private Sub dt_RowChanging(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles dt.RowChanging
largerPictureBox.Image = Nothing
End Sub
I use above code but below dt variable I use below this code
Code:
Private Sub PopulateDataGridView()
Try
Dim dt = New DataTable()
Dim query = "select ITM,ITC,QOH,PRS,FILENAME1,FILENAME2,FILENAME3,FILENAME4 FROM ITEM"
Using adapter As New OleDbDataAdapter(query, cn.ToString)
adapter.Fill(dt)
End Using
Me.DataGridView1.DataSource = dt
For x As Integer = 4 To 7
Me.DataGridView1.Columns(x).Visible = False
Next
ExPictureBox1.PrePath = Pathimage & "\"
ExPictureBox2.PrePath = Pathimage & "\"
ExPictureBox3.PrePath = Pathimage & "\"
ExPictureBox4.PrePath = Pathimage & "\"
ExPictureBox1.DataBindings.Add("FileName", dt, "FILENAME1")
ExPictureBox2.DataBindings.Add("FileName", dt, "FILENAME2")
ExPictureBox3.DataBindings.Add("FileName", dt, "FILENAME3")
ExPictureBox4.DataBindings.Add("FileName", dt, "FILENAME4")
Catch myerror As OleDbException
MessageBox.Show("Error: " & myerror.Message)
Finally
End Try
End Sub
is there a solution without removing the code that I marked in red?
-
Oct 30th, 2021, 12:26 PM
#9
Re: autofit image in multi picturebox and then clicked pop up full size image in VB.N
Change the red highlighted line to…
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 31st, 2021, 09:41 AM
#10
Thread Starter
Lively Member
Re: autofit image in multi picturebox and then clicked pop up full size image in VB.N
 Originally Posted by .paul.
Change the red highlighted line to…
Dear Mr. .paul.
thank you very much. You are my teacher. Sorry I'm late to reply. I mark my post resolved and rate my post to you.
Thanks
roy88
Tags for this Thread
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
|