0

I'm using a BindingList bound to a checkedListBox which contains FileInfo objects. I want to load an image into a PictureBox when the checkedListBox_SelectedIndexChanged event is fired, since each FileInfo object represents an image file.

My problem is that I can't figure out how to access the FullName property of a FileInfo object from the object selected in the checkedLisBox.

Any help will be appreciated :) Thanks!

4

2 回答 2

2

您需要将所选对象转换为 FileInfo:

String Fullname = "";
FileInfo Info = checkedListBox1.SelectedItem as FileInfo;
if (Info != null)
{
    Fullname = Info.FullName;
}
于 2012-09-06T21:40:20.943 回答
1

您必须将 checkedListBox.SelectedItem 强制转换为 FileInfo 并在 SelectedIndexChanged 事件处理程序中读取其 FullName。

于 2012-09-06T21:33:38.497 回答