c# - How can i find out the Last row in a datagridview and write it to text file -
i find last row of datagridview , write particular row data text file can 1 me
i give sample code, may help.
list<string> lstcontents = new list<string>(); foreach (datagridviewcell cell in mydatagrid.rows[mydatagrid.rowcount - 1].cells) { lstcontents .add((string)cell.value); } string mydata= string.join(",", lstcontents.toarray());
now using streamwriter can write string file. can use separator. have used "," comma here. ///this append data text file...
using (streamwriter sw = new streamwriter(filepath, true)) { sw.writeline(mydata); }
Comments
Post a Comment