private void ValidateForm(TextBox txtPurpose, DatePicker txtDateRequired, ComboBox comboPRType, DataGrid dgItems, out bool Validated) { Validated = false; if (dgItems.Items.Count <= 0) { dgItems.FlagAsError(); return; } dgItems.FlagAsNormal(); if (txtPurpose.Text.IsNullOrEmpty()) { txtPurpose.FlagAsError(); return; } txtPurpose.FlagAsNormal(); if (comboPRType.SelectedIndex == -1) { comboPRType.FlagAsError(); return; } comboPRType.FlagAsNormal(); if (txtDateRequired.Text.IsNullOrEmpty()) { txtDateRequired.FlagAsError(); return; } txtDateRequired.FlagAsNormal(); Validated = true; }