The code below ran without any error. When I double-click on the cell in the dataGridView2,
the form Reservation1 opened, but the three value below are not in the textbox. The three
text boxes are blank. The other two values are in the form Reservation1.
R1.Property_Name.Text = this.dataGridView2.CurrentRow.Cells[0].Value.ToString(); --> This value is in the form Reservation1
R1.Unit_Number.Text = this.dataGridView2.CurrentRow.Cells[1].Value.ToString(); --> This value is in the form Reservation1
R1.Date_Reserved.Text = Date_Reserved.ToString(); --> This value is not in the textbox of form Reservation1
R1.Lease_Months.Text = "6"; --> This value is not in the textbox of form Reservation1
R1.Reservation_Cancelled.Text = "No"; --> This value is not in the textbox of form Reservation1
the form Reservation1 opened, but the three value below are not in the textbox. The three
text boxes are blank. The other two values are in the form Reservation1.
R1.Property_Name.Text = this.dataGridView2.CurrentRow.Cells[0].Value.ToString(); --> This value is in the form Reservation1
R1.Unit_Number.Text = this.dataGridView2.CurrentRow.Cells[1].Value.ToString(); --> This value is in the form Reservation1
R1.Date_Reserved.Text = Date_Reserved.ToString(); --> This value is not in the textbox of form Reservation1
R1.Lease_Months.Text = "6"; --> This value is not in the textbox of form Reservation1
R1.Reservation_Cancelled.Text = "No"; --> This value is not in the textbox of form Reservation1
The value is not in the textbox of a form when a form is opened:
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
string Apartment_Status;
DateTime Date_Reserved = DateTime.Now.Date;
MessageBox.Show("Date_Reserved = " + Date_Reserved);
object value = this.dataGridView2.CurrentRow.Cells[7].Value.ToString();
if (value is DBNull) { return; }
Apartment_Status = value.ToString();
MessageBox.Show("Apartment_Status = " + Apartment_Status);
switch (Apartment_Status)
{
case "Reserved":
Reservation1 R1 = new Reservation1();
R1.Property_Name.Text = this.dataGridView2.CurrentRow.Cells[0].Value.ToString(); --> This value is in the form Reservation1
R1.Unit_Number.Text = this.dataGridView2.CurrentRow.Cells[1].Value.ToString(); --> This value is in the form Reservation1
R1.Date_Reserved.Text = Date_Reserved.ToString(); --> This value is not in the textbox of form Reservation1
R1.Lease_Months.Text = "6"; --> This value is not in the textbox of form Reservation1
R1.Reservation_Cancelled.Text = "No"; --> This value is not in the textbox of form Reservation1
R1.Show();
break;
case "Occupied":
Tenant T1 = new Tenant();
T1.Property_Name.Text = this.dataGridView2.CurrentRow.Cells[0].Value.ToString();
T1.Unit_Number.Text = this.dataGridView2.CurrentRow.Cells[1].Value.ToString();
T1.Show();
break;
case "Vacant":
Reservation1 R2 = new Reservation1();
R2.Property_Name.Text = this.dataGridView2.CurrentRow.Cells[0].Value.ToString();
R2.Unit_Number.Text = this.dataGridView2.CurrentRow.Cells[1].Value.ToString();
R2.Show();
break;
default:
break;
}
}