BindingList<T> and checkedListBox
-
30-06-2021 - |
Pregunta
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!
Solución
You need to cast the selected object to FileInfo:
String Fullname = "";
FileInfo Info = checkedListBox1.SelectedItem as FileInfo;
if (Info != null)
{
Fullname = Info.FullName;
}
Otros consejos
You have to cast the checkedListBox.SelectedItem to FileInfo and read its FullName within the SelectedIndexChanged event handler.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow