Skip to content

Instantly share code, notes, and snippets.

@joebuschmann
Created December 18, 2014 20:24
Show Gist options
  • Save joebuschmann/c54d16c3cff101960f91 to your computer and use it in GitHub Desktop.
Save joebuschmann/c54d16c3cff101960f91 to your computer and use it in GitHub Desktop.
The correct way to display a WinForms modal dialog
private void btnShowUserDialog_Click(object sender, EventArgs e)
{
using (var form = new SelectUserForm())
{
form.SelectedUsers = SelectedUsers;
if (form.ShowDialog(this) == DialogResult.OK)
{
SelectedUsers = form.SelectedUsers;
lblUsers.Text = SelectedUsers.Values.ToDelimitedString(", ");
lblUsers.Tag = SelectedUsers.Keys.ToDelimitedString(",");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment