Skip to content

Instantly share code, notes, and snippets.

@joebuschmann
Last active August 29, 2015 14:11
Show Gist options
  • Select an option

  • Save joebuschmann/caede8ad756c68832512 to your computer and use it in GitHub Desktop.

Select an option

Save joebuschmann/caede8ad756c68832512 to your computer and use it in GitHub Desktop.
The correct way to validate and close a modal form
private void btnOK_Click(object sender, EventArgs e)
{
if (Validate())
{
_selectedUsers.Clear();
foreach (var user in _allUsers.Where(u => u.Selected))
_selectedUsers.Add(user.UserId, user.UserName);
}
else
DialogResult = DialogResult.None;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment