2012-01-18 12 views
0

エラー:パスは正当な形式ではありません。 (メッセージボックスに空のパス/メッセージが表示されます)。listview1アイテムが選択されたときにimagelist1に画像を取得する

If (ListView1.SelectedItems.Count > 0) Then 
     Dim selection As ListViewItem = ListView1.SelectedItems(0) 
     PictureBox1.Image = System.Drawing.Image.FromFile(selection.Text) 
End If 
+0

選択テキストは、理想的に画像のファイル名になりselection.Text –

+0

ものです。 – Farook

+0

@farook:[ListView-Itemのテキスト](http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.text.aspx)は空の文字列です。あなたの問題を解決するのか? –

答えて

0
If (ListView1.SelectedItems.Count > 0) Then 
    try 
     Dim selection As string = ListView1.FocusedItem.text 
     PictureBox1.Image = System.Drawing.Image.FromFile(selection) 
    catch ex as Exception 
     msgbox (ex.message.tostring) 
    enD Try 
End If 
+0

パスは法的形式ではありません! – Farook

+0

私の問題は解決しません。基本的に私が望むのは、imagelist1がlistview1から選択した画像を表示することです。 – Farook

+0

Tim、私のコードをあなたが推奨するコードに変更しましょう。あなたのリンクからコードを試しました。 listview1にチェックボックスを表示します。 – Farook

関連する問題