public RentCarForm(ClientClass client) { this.client = client; InitializeComponent(); int lHeight = AutoParkService.GetAvailableCars().Count * 13 + 10; listBox1.DataSource = AutoParkService.GetAvailableCars(); button1.Location = new Point(button1.Location.X, button1.Location.Y - (listBox1.Height - lHeight)); listBox1.Height = lHeight; Height = lHeight + 150; }
private void button1_Click(object sender, EventArgs e) { if (AutoParkService.GetAvailableCars().Count == 0) { MessageBox.Show("No cars are available for renting now", "Autopark"); return; } else { this.Hide(); RentCarForm rc = new RentCarForm(client); rc.Closed += (s, args) => this.Show(); rc.Show(); } }