listbox (listStorageLocations)가 있습니다. listStorageLocationsBindingSource라는 BindingSource에 바인딩 된 목록 상자가 있습니다. 이 BindingSource는 내 Settings.Default.StorageLocations의 StringDictionary 항목 컬렉션에 바인딩됩니다. 목록 상자의 데이터 소스는 바인딩 소스로 설정됩니다. 나는 내 인생에서 (특별히 테스트 항목을 추가하지 않는 한)이 불쾌한 목록 상자에 표시 할 항목을 얻을 수 없다. 나는 78에서 내 팔을 들고 시도했습니다ListBox가 Specialized.StringDictionary에 바인딩되지 않았습니다.
private void btnAddStorageLocation_Click(object sender, EventArgs e)
{
if (!txtStorageLocation.Text.Equals("") && !(txtStorageLocationName.Text.Equals("") &&
!(StorageLocationsContainsPath(txtStorageLocation.Text)) &&
!(StorageLocationsContainsName(txtStorageLocationName.Text))))
{
Settings.Default.StorageLocations.Add(txtStorageLocationName.Text, txtStorageLocation.Text);
}
Settings.Default.Save();
listStorageLocationsBindingSource.ResetBindings(false);
}
:
이양식 초기화 :
listStorageLocations.DisplayMember = "Key";
listStorageLocations.ValueMember = "Value";
listStorageLocationsBindingSource.DataSource = Settings.Default.StorageLocations;
listStorageLocations.DataSource = listStorageLocationsBindingSource;
if (Settings.Default.StorageLocations == null)
Settings.Default.StorageLocations = new StringDictionary();
버튼 로직, 새로운 저장 위치를 추가하려면 여기를
는 일부 코드입니다 각도로 7 번 뛰어 오르고, 내 머리에 아무 소용이 없다. 내가 놓친 몇 가지 어리석은 세부 사항입니까?오 물론 또한 내 StringDictionary에서 일부 intial 값을 가져 오기 위해 Settings.Default.Save()를 호출합니다. 물론 응용 프로그램을 다시 시작하면 아무 것도 작동하지 않습니다. 항목이 없습니다.
아무도 어떤 경험이 있습니까? – Jack