private void okButton_Click(object sender, EventArgs e) { if (authorsListbox.SelectedItem != null) { var item = authorsListbox.SelectedItem as AuthorItem; if (item != null) { var author = m_context.GetAuthor(item.Id); if (author != null) { CallResultCallback(author); } } } Close(); }