我正在使用BindingList綁定到包含FileInfo對象的checkedListBox。 當checkedListBox_SelectedIndexChanged事件被觸發時,我想將圖像加載到PictureBox中,因爲每個FileInfo對象都表示一個圖像文件。綁定列表<T>和checkedListBox
我的問題是,我不知道如何從checkedLisBox中選擇的對象訪問FileInfo對象的FullName屬性。
任何幫助將不勝感激:) 謝謝!
我正在使用BindingList綁定到包含FileInfo對象的checkedListBox。 當checkedListBox_SelectedIndexChanged事件被觸發時,我想將圖像加載到PictureBox中,因爲每個FileInfo對象都表示一個圖像文件。綁定列表<T>和checkedListBox
我的問題是,我不知道如何從checkedLisBox中選擇的對象訪問FileInfo對象的FullName屬性。
任何幫助將不勝感激:) 謝謝!
你需要選擇的對象轉換爲FileInfo的:
String Fullname = "";
FileInfo Info = checkedListBox1.SelectedItem as FileInfo;
if (Info != null)
{
Fullname = Info.FullName;
}
您必須將checkedListBox.SelectedItem轉換爲FileInfo並在SelectedIndexChanged事件處理程序中讀取其FullName。
這幫助了很多 - 謝謝! – thilemann