데이터를 보관할 하나의 목록 상자가 있어야하는 응용 프로그램에서 작업하고 있습니다. 목록 상자에서 개체를 삭제할 때목록 상자 항목의 원점을 결정하십시오.
은 좀 문제가 있어요. 이 문제는 두 개의 개별 목록에있는 항목으로 목록 상자를 채울 때 작용합니다.
일반적으로 객체를 삭제하려면 색인을 얻은 다음 별도의 클래스에서 목록에서 제거한 다음 변경 사항을 반영하여 목록 상자를 다시로드하지만 특정 인스턴스에서는 객체가있는 목록 상자를 채울 필요가 있습니다. 두 개의 서로 다른 목록과 두 개의 목록 중 하나에서 삭제할 개체의 출처를 결정, 글쎄,이 작업을 수행하는 방법을 잘 모르겠습니다.
이 코드는 목록 상자 컨트롤을 채 웁니다. // 목록 상자의 모든 항목 지우기 ViewListBox.Items.Clear();
//create the lists
List listOfPickups = visits.listPickups();
List listOfdeliveries = visits.listDeliveries();
//populate
ViewListBox.Items.AddRange(listOfPickups.ToArray());
ViewListBox.Items.AddRange(listOfdeliveries.ToArray());
이렇게하면 목록에서 하나의 목록 만로드 할 때 삭제됩니다.
if (ViewListBox.SelectedIndex < 0)
{
EditSelectBtn.Enabled = false;
DeleteSelectBtn.Enabled = false;
}
else
{
if (MessageBox.Show("are you sure you want to delete the selected item?", "Are You Sure?", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
visits.removePickup(this.ViewListBox.SelectedIndex);
//refresh listbox.
updateList("pickups");
}
else
{
//clicked no so do nothing!
ViewListBox.ClearSelected();
}
}
어떤 도움이 크게 appretiated 것입니다.
WPF 또는 윈폼? –
메트로? WinForms? WPF? 실버 라이트? 윈도우 폰? ASP.Net? MonoTouch? – SLaks