alancordez Posted April 28, 2023 Report Posted April 28, 2023 (edited) For the last part of my project (then I am finally set with everything 🙂 ) I need to write a kg Value from a textbox (name: txtboxCabOa) into a specific Compartment for example into "CAB OA" with one single Button click.  My code looks like this but I am really confused with this one, because there is only a possibility with a hard coded list. Hopefully there is a workaround for one CAB like OA or OB or OC. Greetings Patrick  namespace EFBWPF { public partial class MainWindow : Window { List<FsPayloadStation> payloadStations = null; private void btnSendData_Click(object sender, RoutedEventArgs e) { FSUIPCConnection.PayloadServices.RefreshData(); // Assign the payload stations to our class level variable for easier access this.payloadStations = FSUIPCConnection.PayloadServices.PayloadStations; //Assigning only one Cabin FsPayloadStation CabOA = this.nudWeight.Value = (decimal)station.WeightKgs; double WeightKGs = 0; if (double.TryParse(txtboxCabOa.Text, out newWeightKGs)) FSUIPCConnection.PayloadServices.WriteChanges(); } } }  Edited April 28, 2023 by alancordez
Paul Henty Posted April 28, 2023 Report Posted April 28, 2023 Hi Patrick, You can search for a PayloadStation by name using the Find() method: private void btnSendData_Click(object sender, RoutedEventArgs e) { FSUIPCConnection.PayloadServices.RefreshData(); // Assign the payload stations to our class level variable for easier access this.payloadStations = FSUIPCConnection.PayloadServices.PayloadStations; //Assigning only one Cabin // Find PayloadStation by name (NOTE: The matching is case-sensitive) FsPayloadStation CabOA = this.payloadStations.Find(ps => ps.Name == "CAB OA"); if (CabOA != null) { // Payload station found double newWeightKGs = 0; if (double.TryParse(txtboxCabOa.Text, out newWeightKGs)) { CabOA.WeightKgs = newWeightKGs; } } FSUIPCConnection.PayloadServices.WriteChanges(); } Â Paul Â
alancordez Posted April 30, 2023 Author Report Posted April 30, 2023 Thank you Paul, it works excellent. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now