Question

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!

Was it helpful?

Solution

You need to cast the selected object to FileInfo:

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top