c# - How do I delete selected item from a combo box in the text file -


so list in combobox comes text file. program allows user choose 1 item combobox. selected item should removed combobox , text file clicking button.

this code allows program items text file combobox:

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 values text file (int = 0; < 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; (int = 0; < 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; } 

this how i'm letting program know i'm done choosing item:

private void btn_buy_click(object sender, eventargs e) {     new messagebox_tybuying().show();     cmbbx_opts.items.remove(cmbbx_opts.selecteditem); } 

so when started program, selected item in combobox removed, not on text file. how do it??

there's no such thing "removing line text file". can is:

approach 1)
open original file , either read lines list<string>. then, iterate on these list entries , remove 1 needs removed. then, write list entries file.

approach 2)
rename original file "backup" file. open backup file reading , new file original file name writing. read backup file line line. write every line output file apart line want remove.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -