Hi Guys,
I've been playing around with this for hours and seem to be getting nowhere fast!
I have 2 forms (both with datagridviews). User clicks on form one and gets form two containing details for the row they clicked on and the ability to edit those details. When the user makes changes in the details form and closes it i want the main form to reflect those changes.
I have placed this code on the details form;
Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
If MessageBox.Show("Are you sure you want to close?", "Stop entering order?", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
dlgOrd.OrdersGridReload()
Me.Close()
End If
hoping that it will run this code (which is a sub on the main form);
Public Sub OrdersGridReload()
Me.Sp_PFillOrderGridTableAdapter.Fill(Me.DsOrders.sp_PFillOrderGrid)
DGVOrders.Width = Me.Width
DGVOrders.Height = (Me.Height / 100) * 85
Me.dwOrdNum.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 7.5
Me.szAccCode.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 7.5
Me.szName.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 14
Me.dtOrdDate.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 7.5
Me.szAuthBy.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 10
Me.szStatus.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 7.5
Me.szNotes.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 22
Me.dwrValue.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 6
Me.DtCompDate.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 8.5
Me.DGVOrders.RowHeadersWidth = Screen.PrimaryScreen.WorkingArea.Width / 100 * 2.5
Dim i As Integer
Dim r As DataGridViewRow
i = 0
For Each r In Me.DGVOrders.Rows
Me.DGVOrders.Rows(i).DefaultCellStyle.BackColor = Color.FromArgb(Me.DGVOrders.Rows(i).Cells("dwColourRef").Value)
i = i + 1
Next
Me.DGVOrders.Refresh()
End Sub
Stepping thro the code it all appears to work as required, however the screen is not updated.
Strangely, adding a button to the main form with the following code works!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OrdersGridReload()
End Sub
Can anyone tell me whats going on or where i'm going wrong?
Thanks,
Noel.
I've been playing around with this for hours and seem to be getting nowhere fast!
I have 2 forms (both with datagridviews). User clicks on form one and gets form two containing details for the row they clicked on and the ability to edit those details. When the user makes changes in the details form and closes it i want the main form to reflect those changes.
I have placed this code on the details form;
Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
If MessageBox.Show("Are you sure you want to close?", "Stop entering order?", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
dlgOrd.OrdersGridReload()
Me.Close()
End If
hoping that it will run this code (which is a sub on the main form);
Public Sub OrdersGridReload()
Me.Sp_PFillOrderGridTableAdapter.Fill(Me.DsOrders.sp_PFillOrderGrid)
DGVOrders.Width = Me.Width
DGVOrders.Height = (Me.Height / 100) * 85
Me.dwOrdNum.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 7.5
Me.szAccCode.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 7.5
Me.szName.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 14
Me.dtOrdDate.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 7.5
Me.szAuthBy.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 10
Me.szStatus.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 7.5
Me.szNotes.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 22
Me.dwrValue.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 6
Me.DtCompDate.Width = Screen.PrimaryScreen.WorkingArea.Width / 100 * 8.5
Me.DGVOrders.RowHeadersWidth = Screen.PrimaryScreen.WorkingArea.Width / 100 * 2.5
Dim i As Integer
Dim r As DataGridViewRow
i = 0
For Each r In Me.DGVOrders.Rows
Me.DGVOrders.Rows(i).DefaultCellStyle.BackColor = Color.FromArgb(Me.DGVOrders.Rows(i).Cells("dwColourRef").Value)
i = i + 1
Next
Me.DGVOrders.Refresh()
End Sub
Stepping thro the code it all appears to work as required, however the screen is not updated.
Strangely, adding a button to the main form with the following code works!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OrdersGridReload()
End Sub
Can anyone tell me whats going on or where i'm going wrong?
Thanks,
Noel.