窗體上放一個PictureBox,兩個CommandButton,一個FileListBox

成都創(chuàng)新互聯(lián)公司專注于企業(yè)全網(wǎng)營銷推廣、網(wǎng)站重做改版、安寧網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、HTML5建站、商城網(wǎng)站開發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)營銷網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計(jì)等建站業(yè)務(wù),價格優(yōu)惠性價比高,為安寧等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
Private Sub Command1_Click()
If File1.ListIndex = 0 Then
ShowPic File1.ListCount - 1
Else
ShowPic File1.ListIndex - 1
End If
End Sub
Private Sub Command2_Click()
If File1.ListIndex = File1.ListCount - 1 Then
ShowPic 0
Else
ShowPic File1.ListIndex + 1
End If
End Sub
Private Sub Form_Load()
File1.Visible = False
File1.Pattern = "*.jpg;*.gif" '可以瀏覽的文件類型,使用分號隔開
File1.Path = App.Path '改成你需要瀏覽的目錄,比如"C:\Pic"
If File1.ListCount 1 Then '目錄中圖片在兩張以上可以瀏覽
ShowPic 0
Exit Sub
ElseIf File1.ListCount = 1 Then '目錄中只有一張圖片時只顯示這一張
ShowPic 0
End If
Command1.Enabled = False
Command2.Enabled = False
End Sub
Private Sub ShowPic(Index As Long)
File1.ListIndex = Index
Picture1.Picture = LoadPicture(File1.Path "\" File1.List(Index))
End Sub
如果對您有幫助,請記得采納為滿意答案,謝謝!祝您生活愉快!
vaela
1.首先建立一個基于Microsoft?.NET?Framework?2.0以上的VB.NET解決方案。
2.在窗體上面添加一個PictureBox控件,并綁定到父容器里面(綁定到父容器的操作可以不去實(shí)現(xiàn))。
3.給PictureBox.Image指定路徑,這里以“C:\Windows\Web\Wallpaper\Windows\img0.jpg”為例子,當(dāng)然這張圖片在Windows?7旗艦版下面會有的。
4.添加代碼:
Public?Class?Form1
Private?Sub?Form1_Load(sender?As?Object,?e?As?EventArgs)?Handles?MyBase.Load
Randomize()
Dim?xScn?As?UInteger?=?My.Computer.Screen.Bounds.Width
Dim?yScn?As?UInteger?=?My.Computer.Screen.Bounds.Height
ReLine:
Dim?xShow?As?Integer?=?Int((xScn?+?1)?*?Rnd())?-?Me.Width
Dim?yShow?As?Integer?=?Int((yScn?+?1)?*?Rnd())?-?Me.Height
Me.FormBorderStyle?=?Windows.Forms.FormBorderStyle.None
PictureBox1.Image?=?Image.FromFile("C:\Windows\Web\Wallpaper\Windows\img0.jpg")
PictureBox1.SizeMode?=?PictureBoxSizeMode.StretchImage
If?xShow?=?0?And?yShow?=?0?Then
Me.Location?=?New?Point(xShow,?yShow)
Else
GoTo?ReLine
End?If
Me.Show()
End?Sub
End?Class
5.我是使用?Visual?Studio?2012?Ultimate?開發(fā)的,若有錯誤請參考請他方法進(jìn)行修改
轉(zhuǎn)換成位圖肯定是可以瀏覽的,WMF文件沒試過。
你可以將圖片以二進(jìn)制形式存儲在數(shù)據(jù)庫中,如果是SQL Server,對應(yīng)字段的類型應(yīng)該是image。
我說選把打開多個圖片路徑加載到一個listbox里,利用listbox寫代碼
Private Sub picbox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If ListBox1.SelectedIndex = count Then
Try
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
Catch
ListBox1.SelectedIndex = 0
End Try
End If
picbox.Image = ListBox1.SelectedItem.ToString
End Sub
Private?Sub?Button1_Click(sender?As?Object,?e?As?EventArgs)?Handles?Button1.Click
'建立新的系統(tǒng)進(jìn)程????
Dim?process?As?New?System.Diagnostics.Process()
If?RadioButton1.Checked?Then
'設(shè)置文件名,此處為圖片的真實(shí)路徑+文件名????
process.StartInfo.FileName?=?"c:\a.bmp"
'設(shè)置進(jìn)程運(yùn)行參數(shù)????
process.StartInfo.Arguments?=?"rundll32.exe?shimgvw.dll"
Else
process.StartInfo.FileName?=?"mspaint.exe"
process.StartInfo.Arguments?=?"c:\a.bmp"
End?If
'此項(xiàng)為是否使用Shell執(zhí)行程序,因系統(tǒng)默認(rèn)為true,此項(xiàng)也可不設(shè),但若設(shè)置必須為true????
'process.StartInfo.UseShellExecute?=?True
'此處可以更改進(jìn)程所打開窗體的顯示樣式,可以不設(shè)????
'process.StartInfo.WindowStyle?=?System.Diagnostics.ProcessWindowStyle.Hidden
process.Start()
process.Close()
End?Sub
本文標(biāo)題:關(guān)于vb.net設(shè)置圖片預(yù)覽的信息
路徑分享:http://www.yijiale78.com/article40/docghho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、定制網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站排名、網(wǎng)站內(nèi)鏈、營銷型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)