tags:

views:

37

answers:

0

i got a code to add rows in a datagrid which adds only one row but i need to add more than one row

for each(DataGridViewRow^ row in dataGridView1->Rows)
 {
if(row->Cells[0]->Value != nullptr)
     {
     System::Int32 nValue = row->Index;
     String ^strFood =  dataGridView1->Rows[nValue]->Cells["FoodName"]->Value->ToString() ;
     String ^strFoodCalories =  dataGridView1->Rows[nValue]->Cells["Calories"]->Value->ToString() ;
     String ^food=dataGridView1->Rows[nValue]->Cells["Calories"]->Value->ToString() ;
      dataGridView2->Rows[0]->Cells[0]->Value = strFood;
      dataGridView2->Rows[0]->Cells[1]->Value = strFoodCalories;

  }