Resolved how to transfer data from one grid view to a text box in another user control

sock1992

Well-known member
Joined
May 20, 2020
Messages
107
Programming Experience
Beginner
When the user double clicks on one of the bookings within the grid view, i would like to transfer the Id to a text box in a separate user control. Any ideas of how could I achieve this? Thankyou

Attempting to transfer the ID to another user Control:
    private void availableBookings_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            User_Control.Uc_bookingDetails bd = new User_Control.Uc_bookingDetails();
            bd.txtSchedule.Text = availableBookings.Rows[e.RowIndex].Cells[0].Value.ToString();
            ShowUserControl(new User_Control.Uc_bookingDetails());
        }

        private void ShowUserControl(Control control)
        {
            addBookingPanel.Controls.Clear();

            control.Dock = DockStyle.Fill;
            control.BringToFront();
            control.Focus();

            addBookingPanel.Controls.Add(control);
        }

Does anyone know why the above code wouldnt work?

when it switches to the next user Control the text box (txtSchedule) is blank
 
Last edited:
Yes, the instance on line 3 is different from the instance on line 5.
 
Back
Top Bottom