Page 1 of 1

OMG so simple yet so hard picturebox help

Posted: Sat Aug 11, 2012 5:14 pm
by muttley1968
Okay I want to save an image from a webpage in a way like IE or chrome ect I have tried this code yet it does not work and I have no IDEA why
Code: Select all
        Try
            Dim pbx As New PictureBox
            pbx.ImageLocation = ToolStrip1.Text
            Dim sfd As New SaveFileDialog
            sfd.Title = "Save your Image as...."
            sfd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyPictures
            sfd.Filter = "Jpeg files (*.jpg)|*.jpg|Bitmap files (*.bmp)|*.bmp"
            Dim result As DialogResult = sfd.ShowDialog
            If result = Windows.Forms.DialogResult.OK Then
                If sfd.FileName <> String.Empty Then
                    Dim MyImageFormat As System.Drawing.Imaging.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg
                    If sfd.FileName.ToString.ToUpper.EndsWith("JPG") Then
                        MyImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg
                    ElseIf sfd.FileName.ToString.ToUpper.EndsWith("BMP") Then
                        MyImageFormat = System.Drawing.Imaging.ImageFormat.Bmp
                    End If
                    pbx.Image.Save(sfd.FileName, MyImageFormat)
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
Any help would be most aprechated

Re: OMG so simple yet so hard picturebox help

Posted: Sat Aug 11, 2012 6:42 pm
by M1z23R
If it is from internet then why not use my.computer.network.downloadfile(toolstrip.text, sfd.filename) ?

Re: OMG so simple yet so hard picturebox help

Posted: Sat Aug 11, 2012 8:24 pm
by muttley1968
Mizzar I love you haha I had not thought of that needed a little tweaking but the compleat code is this if anyone else should need it
Code: Select all
  Try
            Dim label As New Label
            label.Text = ToolStripStatusLabel1.Text
            Dim sfd As New SaveFileDialog
            sfd.Title = "Save your Image as...."
            sfd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyPictures
            sfd.Filter = "Jpeg files (*.jpg)|*.jpg|Bitmap files (*.bmp)|*.bmp"
            Dim result As DialogResult = sfd.ShowDialog
            If result = Windows.Forms.DialogResult.OK Then
                If sfd.FileName <> String.Empty Then
                    Dim MyImageFormat As System.Drawing.Imaging.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg
                    If sfd.FileName.ToString.ToUpper.EndsWith("JPG") Then
                        MyImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg
                    ElseIf sfd.FileName.ToString.ToUpper.EndsWith("BMP") Then
                        MyImageFormat = System.Drawing.Imaging.ImageFormat.Bmp
                    End If
                    My.Computer.Network.DownloadFile(label.Text, sfd.FileName)
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

Re: OMG so simple yet so hard picturebox help

Posted: Sat Aug 11, 2012 9:01 pm
by muttley1968
okay ones again needing help but does anyone know how to refresh the controls in a toolstrip I know
toolstrip.refresh
but that is not working the way I want I want to it remove all items and then put them all back again just I am loading items from a listbox
into a toolstrip that has to preset buttons and when I add a new one it is realoading the listbox items twise soo how can I fix this please

Re: OMG so simple yet so hard picturebox help

Posted: Sat Aug 11, 2012 9:07 pm
by MrAksel
ToolStrip.Items.Clear() ?

Re: OMG so simple yet so hard picturebox help

Posted: Sat Aug 11, 2012 9:39 pm
by muttley1968
Well i would use this but it will clear the 2 Buttons that i need to keep that are like allways there :P ?......

Re: OMG so simple yet so hard picturebox help

Posted: Sun Aug 12, 2012 12:28 am
by M1z23R
Code: Select all
for each tsi as toolstripitem in toostrip.items
if typeof tsi is toolstripbutton and tsi.text ="YOURBUTTONTOSTAY" then
else
toolstrip.items.remove(tsi)
end if
next
Edit, this will remove every item in toolstrip except the one with text YOURBUTTON....

Re: OMG so simple yet so hard picturebox help

Posted: Sun Aug 12, 2012 1:51 pm
by DeveloperJacob

Re: OMG so simple yet so hard picturebox help

Posted: Sun Aug 12, 2012 3:39 pm
by muttley1968
DeveloperJacomb I would use yours and it is amazing but tbh that would then just be copying and pasting most of what I need soo not doing it my self I mutch prefer giving it ago my self then asking you lot for help if I cant get it atleast that way it is my own or rather ours then just some random of the internet that I have changed the graphics of