CSharpTutor.Controls.ContactListControl.BtnRemoveListClick C# (CSharp) Method

BtnRemoveListClick() private method

remove the selected contact list
private BtnRemoveListClick ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void BtnRemoveListClick(object sender, EventArgs e)
        {
            try
            {
                if (LstLists.SelectedItem != null)
                {
                    //clean up the response and request areas
                    FrmMain.RequestString = string.Empty;
                    FrmMain.ResponseString = string.Empty;

                    string strRequest;
                    string strResponse;

                    var selectedList = (ContactListDetails) LstLists.SelectedItem;

                    Cursor.Current = Cursors.WaitCursor;

                    OperationsComponent.DeleteContactList(CredentialsDetails, selectedList.Id, out strRequest,
                                                          out strResponse);

                    Cursor.Current = Cursors.Default;

                    _contactList.Remove(selectedList);
                    SetListBox();

                    if (_contactList.Count == 0)
                        BtnRemoveList.Enabled = false;

                    FrmMain.RequestString = strRequest;
                    FrmMain.ResponseString = strResponse;
                }
                else
                {
                    MessageBox.Show(Resources.SelectListMessage, Resources.MessageBoxTitle, MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, Resources.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            Cursor.Current = Cursors.Default;
        }