c# - Pass selected row gridview to another gridview on another form -


as still new c#, having trouble passing selected row datagridview1(form 1) datagridview2 (form 2) assuming have pass large number of columns, how do it?

and if it's possible, can while selecting multiple rows , pass data grid-view accordingly?

i have tried passing textbox not ideal

if (tablelistbox.selectedindex == 2)                 {   foreach (datagridviewrow dr in datagridview1.selectedrows)   {       int counter = 0;       id = dr.cells[1].value.tostring();       while (counter < datagridview1.columns.count)       {          columnsheader = datagridview1.columns[counter].headertext;          cellsvalue = dr.cells[counter].value.tostring();          pass += columnsheader + "        " + cellsvalue + "  " + "\n";          counter++;       }    form4 form4 = new form4(pass, dr.cells["deposition date"].value.tostring(), id, tablelistbox.selectedindex, dr.cells["deposition date"].value.tostring());    form4.show();    break;    }   } 

if gridview has bound object, can bound object , send form2, because has information need.

if (tablelistbox.selectedindex == 2)             {                 list<object> sendinglist = new list<object>();                 foreach (datagridviewrow dr in datagridview1.selectedrows)                 {                     int counter = 0;                     sendinglist.add(dr.databounditem);                  }                      form4 form4 = new form4(sendinglist);                     form4.show();                     break;              } 

i assume form4 class has constructor list argument


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -