c# - Transferring all data from dataGridView to a textbox -
here question. have restaurant program in customer chooses wishes eat , data displayed in datagridview. example 6 different dishes = 6 different rows each containing name, amount , price. after need print bill, want information datagridview textbox. rows. how can that?
p.s. i've searched lot there information on how transfer currentrow data textbox i've found.
private void form4_load(object sender, eventargs e) { form1 f1 = new form1(); string billinfo = string.empty; foreach (datagridviewrow row in f1.datagridview1.rows) { billinfo = string.format("{0}{1} {2} {3}{4}", billinfo, row.cells["name"].value, row.cells["amount"].value, row.cells["price"].value, environment.newline); } textbox1.text = billinfo; }
just loop through each row , format column values string, adding system.environment.newline
seperating entries in textbox
.
string billinfo = string.empty; foreach (datagridviewrow row in this.datagridview1.rows) { billinfo = string.format("{0}{1} {2} {3}{4}", billinfo, row.cells["name"].value, row.cells["amount"].value, row.cells["price"].value, environment.newline); } this.textbox1.text = billinfo;
Comments
Post a Comment