2011-10-28 32 views
0

私はfileListBoxを作成し、.jpgファイルでフォルダを探索しました。クリックしたアイテムではpicturebox1が選択されたイメージを表示しましたが、次のアイテムと前のものを選択するボタンを作成できますか?fileListBoxからアイテムを選択

+0

あなたが使用しているWinformsのを、WPFや何かをそれ以外は? [this 'FileListBox'](http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.compatibility.vb6.filelistbox.aspx)を意味しますか? – svick

+0

はいそれは..i Windowsフォームを使用しています –

答えて

0

次:

fileListBox.SelectedIndex = fileListBox.SelectedIndex + 1; 

前回:

fileListBox.SelectedIndex = fileListBox.SelectedIndex-1; 

あなたは

0

[次へ]を選択しますが、最後に、またはこれを実行する前に開始されているかどうかを確認したい、またはキャッチ例外があります。

If fileListBox.SelectedIndex < fileListBox.Items.Count-1 Then 
    fileListBox.SelectedIndex = fileListBox.SelectedIndex+1 
End If 

前の選択:

それは前または次の選択することも可能です場合にも、実際に基づいて、ボタンを有効/無効にすることができます
If fileListBox.SelectedIndex > 0 Then 
    fileListBox.SelectedIndex = fileListBox.SelectedIndex-1 
End If 

btnSelectNext.Enabled = fileListBox.SelectedIndex < fileListBox.Items.Count-1 
btnSelectPrevious.Enabled = fileListBox.SelectedIndex > 0 
関連する問題