Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thank you for your answer.</p> <p>Anyway, I have managed to solve the problem in the following way:</p> <p>1) I have added: </p> <pre><code>private Person FindPerson(string name) { return people.Find(x =&gt; x.Name == name); } </code></pre> <p>2) I have replaced: </p> <pre><code>people[listView1.SelectedItems[0].Index] </code></pre> <p>with "person", where person is: </p> <pre><code>Person person = FindPerson(listView1.SelectedItems[0].Text); </code></pre> <p>where FindPerson is: </p> <pre><code>private Person FindPerson(string name) { return people.Find(x =&gt; x.Name == name); } </code></pre> <p>Anyway, I keep getting error when I try to remove the last remaining contact. Even when I try to select it, not just remove it. Here you can take a look what error is about:</p> <p><strong>IMAGE</strong>: <a href="http://s24.postimg.org/ls4nak6et/Kruzeri.png" rel="nofollow">http://s24.postimg.org/ls4nak6et/Kruzeri.png</a></p> <p>So, this is how it looks like now:</p> <pre><code>private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 0) return; Person person = FindPerson(listView1.SelectedItems[0].Text); textBox1.Text = person.Name; textBox2.Text = person.Hometown; textBox3.Text = person.Address; textBox4.Text = person.Phone; textBox5.Text = person.Email; textBox6.Text = person.AdditionalInfo; dateTimePicker1.Value = person.Birthday; textBox1.ReadOnly = true; textBox2.ReadOnly = true; textBox3.ReadOnly = true; textBox4.ReadOnly = true; textBox5.ReadOnly = true; textBox6.ReadOnly = true; dateTimePicker1.Enabled = false; toolStripButton5.Enabled = true; } </code></pre> <p>and Save button: </p> <pre><code>private void toolStripButton1_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count &gt; 0) { Person person = FindPerson(listView1.SelectedItems[0].Text); person.Name = textBox1.Text; person.Hometown = textBox2.Text; person.Address = textBox3.Text; person.Phone = textBox4.Text; person.Email = textBox5.Text; person.Birthday = dateTimePicker1.Value; person.AdditionalInfo = textBox6.Text; listView1.SelectedItems[0].Text = textBox1.Text; textBox1.ReadOnly = true; textBox2.ReadOnly = true; textBox3.ReadOnly = true; textBox4.ReadOnly = true; textBox5.ReadOnly = true; textBox6.ReadOnly = true; dateTimePicker1.Enabled = false; } else { MessageBox.Show("Nothing is selected ", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); } UserCount(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload