Вопрос

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!

Это было полезно?

Решение

You need to cast the selected object to FileInfo:

String Fullname = "";
FileInfo Info = checkedListBox1.SelectedItem as FileInfo;
if (Info != null)
{
    Fullname = Info.FullName;
}

Другие советы

You have to cast the checkedListBox.SelectedItem to FileInfo and read its FullName within the SelectedIndexChanged event handler.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top