Why does updating a table need the container validate method

Why does updating a table need the container validate method

I have a table dragged and dropped onto a tab page. The save item produces the following code:

Private Sub bindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bindingNavigatorSaveItem.Click
If Me.Validate Then
Me.TopicsBindingSource.EndEdit()
Me.TopicsTableAdapter.Update(Me.DsHasbara.Topics)
Else
System.Windows.Forms.MessageBox.Show(Me, "Validation errors occurred.", "Save", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning)
End If

I have no idea what exactly is being validated. It's a member of the tab control, but the documentation doesn't indicate why it is used here.

dennist

[799 byte] By [dennist] at [2008-1-25]
# 1

Validate sends two events (System.Windows.Forms.Control.Validating and System.Windows.Forms.Control.Validated) to the controls in the container.

We do this because certain controls (like the DataGridView) don't update their list data when we call BindingSource.EndEdit(). Calling Validate() causes the controls to end edit mode and update their list data. Despite the name of the function, there's no extra data validation going on under the hood. It's simply a mechanism for us to insure the DataTable is updated before the call to TableAdapter.Update().

I hope this helps.

Jay Hickerson
Visual Basic Team

JayHickerson at 2007-8-21 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2
Thanks, Jay.

Do I only need to do this when the databound controls are inside a container control? All container controls?

In vs.net 2003, if I had controls and a grid tied to the same source - two different views of the data, I had to perform a dgrd.performlayout() in order for the grid to update.

If the grid is in a container, will I have to add the performlayout in addition to the validate? If not in a container, will I still have to use it, or has that that defect been corrected?

thank again.

dennist

dennist at 2007-8-21 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified