using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace TrackMaker4 { //A form that allows a user to pick pieces for a turnout public partial class Turnout : Form { //These are to be used to be sent back to the parent //of this form int p1 = 1; int p2 = 2; public Turnout() { InitializeComponent(); } public int P1//get or set values for the first piece { set { p1 = value; } get { return p1; } } public int P2//get or set values for the second piece { set { p2 = value; } get { return p2; } } private void bttnOK_Click(object sender, EventArgs e) { //Set the values of p2 and p2 here DialogResult = DialogResult.OK; } private void P1_Click(object sender, EventArgs e) { Button Check = new Button(); //There was an error if I clicked on the form (Missed the button) //This if statement fixed that if (sender.GetType() == Check.GetType()) { //Record which button is clicked //(Much like the tools in Form1) Button clickedButton = (Button)sender; p1 = Convert.ToInt32(clickedButton.Tag); this.pbx1.BackgroundImage = clickedButton.Image; } } //Same of the if statement above private void P2_Click(object sender, EventArgs e) { Button clickedButton = (Button)sender; p2 = Convert.ToInt32(clickedButton.Tag); this.pbx2.BackgroundImage = clickedButton.Image; } private void Turnout_Load(object sender, EventArgs e) { } } }