画像のファイル名を表示するlstFilesという名前をListBox
付けました。リスト ボックスから選択すると、マウスまたはキーボードから選択できます。
画像はPictureBox
pictureBox1内に表示されますが、最後のエントリがリストされた後、トップに戻ろうとして問題が発生しListBox
ています。最後のエントリでキーボードの下矢印を選択し、トップを持っている場合エントリが選択されている場合、最初のエントリで上矢印キーを押すと、同じように一番下のエントリに移動します。
試してみましたが、リストボックス内で動作させることができません
システムドライブ、フォルダー、およびそのコンテンツを表示するための3つの共同リストボックスがあります
private void lstDrive_SelectedIndexChanged_1(object sender, EventArgs e)
{
lstFolders.Items.Clear();
try
{
DriveInfo drive = (DriveInfo)lstDrive.SelectedItem;
foreach (DirectoryInfo dirInfo in drive.RootDirectory.GetDirectories())
lstFolders.Items.Add(dirInfo);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void lstFolders_SelectedIndexChanged_1(object sender, EventArgs e)
{
lstFiles.Items.Clear();
DirectoryInfo dir = (DirectoryInfo)lstFolders.SelectedItem;
foreach (FileInfo fi in dir.GetFiles())
lstFiles.Items.Add(fi);
}
private void lstFiles_SelectedIndexChanged(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile(((FileInfo)lstFiles.SelectedItem).FullName);
//I have tried this, but it makes the selected cursor go straight to the bottom file//
lstFiles.SelectedIndex = lstFiles.Items.Count - 1;
}
}
}