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

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -