Hi Folks
OK I've taken Rhys advice and created a class in my program as follows:
And I create an instance of it to put in the values, then assign it to the list:
Great. So now here I am, adding things to the list and now I need to go back and update something I already added. I can find the index of the necessary list item this way:
What I can't figure out is how to update any of the elements (like CarName) in the listitem. I have the index but nothing I'm trying seems to allow me to change an element within the list. Any ideas?
OK I've taken Rhys advice and created a class in my program as follows:
Code:
public class CarMovement
{
public int Id { get; set; }
public string CarName { get; set; }
public string MoveStatus { get; set; }
public string SourceCtrl { get; set; }
public string DestCtrl { get; set; }
}
And I create an instance of it to put in the values, then assign it to the list:
Code:
List<CarMovement> Movement = new List<CarMovement>();
int iID;
iID = Movement.Count();
iID++;
CarMovement Move = new CarMovement();
Move.Id = iID;
Move.CarName = sCarName;
Move.MoveStatus = "Begin";
Move.SourceCtrl = sCtrlName;
Movement.Add(Move);
Great. So now here I am, adding things to the list and now I need to go back and update something I already added. I can find the index of the necessary list item this way:
Code:
int Idx = Movement.FindIndex(item => item.SourceCtrl == txt.Name);
if (Idx >= 0)
{...}
What I can't figure out is how to update any of the elements (like CarName) in the listitem. I have the index but nothing I'm trying seems to allow me to change an element within the list. Any ideas?