private void BtnFindNode_Click(object sender, EventArgs e)
 {
     try
     {
         CheckTxtBox(TxtInputData.Text);
         int data = Int32.Parse(TxtInputData.Text);
         RefreshListbox();
         string nodeLocated = aNode.Find(data).Data.ToString();
         int    index       = ListBoxOutput.FindString($"[{nodeLocated}");
         TxtInputData.Text = null;
         TxtInputData.Focus();
         ListBoxOutput.SetSelected(index, true);
         MessageBox.Show($"Found Data Node [{nodeLocated}]", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (FormatException ex)
     {
         MessageBox.Show($"{ex.Message.ToString()}", "Prøv igen", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         TxtInputData.SelectAll();
         TxtInputData.Focus();
     }
     catch (NullReferenceException)
     {
         MessageBox.Show($"Node med nr. {TxtInputData.Text} findes ikke", "Prøv igen", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         TxtInputData.SelectAll();
         TxtInputData.Focus();
     }
 }
예제 #2
0
 private void BtnFindNode_Click(object sender, EventArgs e)
 {
     try
     {
         CheckTxtBox(TxtEmail.Text, TxtEmail);
         string email = TxtEmail.Text;
         RefreshListbox();
         TxtEmail.Focus();
         string nodeLocated = aNode.Find(email).Data.Email.ToString();
         int    index       = ListBoxOutput.FindString($"{nodeLocated}");
         ListBoxOutput.SetSelected(index, true);
         MessageBox.Show($"Bruger med email: [{nodeLocated}] er blevet fundet!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (FormatException ex)
     {
         MessageBox.Show($"{ex.Message.ToString()}", "Indtastnings fejl", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     catch (NullReferenceException)
     {
         MessageBox.Show($"Brugeren med email: {TxtEmail.Text} findes ikke", "Prøv igen", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         TxtEmail.SelectAll();
         TxtEmail.Focus();
     }
 }