c# - Adding search function to an invoice application -
i'm new programming , know basic of c#.
i'm doing invoice application in visual studio can store customer name, contact number, address, costs, date of purchase.
i want add search function invoice application retrieve customer there name. these code. please help
namespace invoice_application_final { public partial class main : form {
public main() { initializecomponent(); //listview properties listview.view = view.details; listview.fullrowselect = true; //add column listview listview.columns.add("customer number", 100); listview.columns.add("customer name", 150); listview.columns.add("address", 200); listview.columns.add("invoice number", 100); listview.columns.add("contact number ", 100); listview.columns.add("description", 200); listview.columns.add("costs", 100); listview.columns.add("payment date", 100); } // insert listview private void insert(string custnum, string custname, string address, string invoicenum, string contactnum, string description, string costs, string paymentdate) { // arrays string[] row = { custnum, custname, address, invoicenum, contactnum, description, costs, paymentdate }; listviewitem item = new listviewitem(row); listview.items.add(item); } private void update() { //update listview.selecteditems[0].subitems[0].text = txtcustomernumber.text; listview.selecteditems[0].subitems[1].text = txtcustomername.text; listview.selecteditems[0].subitems[2].text = txtaddress.text; listview.selecteditems[0].subitems[3].text = invoicenumbertxt.text; listview.selecteditems[0].subitems[4].text = contactnumbertxt.text; listview.selecteditems[0].subitems[5].text = descriptiontxt.text; listview.selecteditems[0].subitems[6].text = coststxt.text; listview.selecteditems[0].subitems[7].text = paymentdatetxt.text; // clear textbox after pressing button txtcustomernumber.text = ""; txtcustomername.text = ""; txtaddress.text = ""; invoicenumbertxt.text = ""; contactnumbertxt.text = ""; descriptiontxt.text = ""; coststxt.text = ""; paymentdatetxt.text = ""; } private void delete() { if (messagebox.show("are sure?", "warning", messageboxbuttons.yesno, messageboxicon.warning) == dialogresult.yes) { listview.items.removeat(listview.selectedindices[0]); } // clear textbox after pressing button txtcustomernumber.text = ""; txtcustomername.text = ""; txtaddress.text = ""; invoicenumbertxt.text = ""; contactnumbertxt.text = ""; descriptiontxt.text = ""; coststxt.text = ""; paymentdatetxt.text = ""; } private void btninsert_click(object sender, eventargs e) { //insert insert(txtcustomernumber.text, txtcustomername.text, txtaddress.text, invoicenumbertxt.text, contactnumbertxt.text, descriptiontxt.text, coststxt.text, paymentdatetxt.text); // clear textbox after pressing button txtcustomernumber.text = ""; txtcustomername.text = ""; txtaddress.text = ""; invoicenumbertxt.text = ""; contactnumbertxt.text = ""; descriptiontxt.text = ""; coststxt.text = ""; paymentdatetxt.text = ""; } private void main_load(object sender, eventargs e) { } private void btnupdate_click(object sender, eventargs e) { update(); } private void btndelete_click(object sender, eventargs e) { delete(); } private void btnclear_click(object sender, eventargs e) { txtcustomernumber.text = ""; txtcustomername.text = ""; txtaddress.text = ""; invoicenumbertxt.text = ""; contactnumbertxt.text = ""; descriptiontxt.text = ""; coststxt.text = ""; paymentdatetxt.text = ""; } private void listview1_mouseclick(object sender, mouseeventargs e) { txtcustomernumber.text = listview.selecteditems[0].subitems[0].text; txtcustomername.text = listview.selecteditems[0].subitems[1].text; txtaddress.text = listview.selecteditems[0].subitems[2].text; invoicenumbertxt.text = listview.selecteditems[0].subitems[3].text; contactnumbertxt.text = listview.selecteditems[0].subitems[4].text; descriptiontxt.text = listview.selecteditems[0].subitems[5].text; coststxt.text = listview.selecteditems[0].subitems[6].text; paymentdatetxt.text = listview.selecteditems[0].subitems[7].text; } private void searchtxt_textchanged(object sender, eventargs e) { } } }
if it's windows forms project, believe is, use textbox feature called autocomplete mode: autocompletemode
if project uwp you'd use control called autosuggestbox: autosuggestbox
in code-behind put whatever code want in various event handler when enters search term or clicks on suggestion match.
Comments
Post a Comment