그래서 내 콤보 상자의 목록은 텍스트 파일에서 가져옵니다. 이 프로그램은 사용자가 콤보 상자에서 하나의 항목을 선택할 수 있습니다. 선택한 항목은 단추를 클릭하여 콤보 상자 및 텍스트 파일에서 제거해야합니다.텍스트 파일의 콤보 상자에서 선택한 항목을 삭제하는 방법
private void btn_buy_Click(object sender, EventArgs e)
{
new MessageBox_TYBuying().Show();
cmbBx_opts.Items.Remove(cmbBx_opts.SelectedItem);
}
:
string location = @"C:\\Users\\LMCPENA98\\Desktop\\COE114LPROJECT_MILLENNIUM_PAWS\\MillenniumPaws\\MillenniumPaws\\bin\\Debug\\Files.txt";
string[] temp = File.ReadAllLines(location);
int[] TagNumber = new int[temp.Length];
string[] Breed = new string[temp.Length];
string[] Name = new string[temp.Length];
decimal[] Price = new decimal[temp.Length];
//Getting all the values i the text file
for (int i = 0; i < TagNumber.Length; i++)
{
TagNumber[i] = int.Parse(temp[i].Substring(0, temp[i].IndexOf("-")));
Breed[i] = temp[i].Substring(0, temp[i].IndexOf("+"));
Breed[i] = Breed[i].Substring(Breed[i].LastIndexOf("-") + 1);
Name[i] = temp[i].Substring(0, temp[i].IndexOf("="));
Name[i] = Name[i].Substring(Name[i].LastIndexOf("+") + 1);
Price[i] = decimal.Parse(temp[i].Substring(temp[i].LastIndexOf("=") + 1));
}
Pound p;
for (int i = 0; i < Breed.Length; i++)
{
if (Breed[i] == cmbBx_breed.Text)
{
p = new Pound(TagNumber[i], Name[i], Price[i]);
cmbBx_opts.Items.Add(p.GetEntry());
}
}
}
else
{
cmbBx_breed.Text = null;
}
이것은 내가 항목을 선택 끝났어요 알고있는 프로그램을시키는거야 방법입니다
이 코드는 내 콤보 상자에 텍스트 파일에서 항목을 얻을 수있는 프로그램을 할 수 있습니다
그래서 프로그래밍을 시작했을 때 콤보 상자에서 선택한 항목이 제거되었지만 텍스트 파일에서는 제거되지 않았습니다. 어떻게해야합니까 ??
.json 파일이나 .xml 파일을 사용하지 않는 이유는 무엇입니까? .. 사용하기가 훨씬 쉽고 복잡합니다 .. – Furtiro
내 그룹과 나는 그런 종류의 파일을 아직 사용하는 방법을 모른다. –