Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sir i got error message in inner for-each loop.

C#
private void buttonSelectAllAvailableStops_Click(object sender, EventArgs e)
          {

              bool found = false;
              foreach (DataRowView drv1 in listBoxAvailableStops.Items)
              {
                  foreach (DataRowView drv2 in listBoxSelectedStops.Items)
                  {
                      if (drv1.Row.ItemArray[0].ToString().Equals(drv2.Row.ItemArray[0].ToString()))
                      {
                          found = true;
                          break;
                      }
                  }
                  if (!found)
                  {
                      DataSet dt = ((System.Data.DataSet)(((System.Windows.Forms.BindingSource)listBoxSelectedStops.DataSource)).DataSource);
                      object[] oldRow = drv1.Row.ItemArray;
                      object[] newRow = new object[3];
                      newRow[0] = oldRow[0];
                      newRow[1] = oldRow[0];
                      newRow[2] = oldRow[1];
                      dt.Tables[0].Rows.Add(newRow);
                      listBoxSelectedStops.DataSource = dt;
                  }
                 found = false;
               }
            
          }
Posted

1 solution

Did you try ^]?

I think following links would help. There must be something wrong out of the posted code.
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/ea9a8516-3af7-49d0-9877-6a1ec705531f[^]
http://www.vbforums.com/showthread.php?t=553638[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900