Pergunta

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!

Foi útil?

Solução

You need to cast the selected object to FileInfo:

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

Outras dicas

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top