Have two ListBox. Double-click on the lbSubject element, adds this element to the second lbSelectedSubject. Provided that this element is not already in lbSelectedSubject. The check for the presence of elements goes through the List<int> to which ValueMember is added.
List<int> selectedValueSubject;
private void Form_Load(object sender, EventArgs e)
{
    selectedValueSubject = new List<int>();
    lbSelectedSubject.DisplayMember = "Title";
    lbSelectedSubject.ValueMember = "Id";
    lbSubject.DataSource = bindingSubjectDefault;
    lbSubject.DisplayMember = "Title";
    lbSubject.ValueMember = "Id";
}
private void LbSubject_MouseDoubleClick(object sender, MouseEventArgs e)
{
    int index = lbSubject.IndexFromPoint(e.Location);
    if (index != ListBox.NoMatches)
    {
        int id = (int)lbSubject.SelectedValue;
        if (IsNotConstrain(id, selectedValueSubject.ToArray()))
        {
            selectedValueSubject.Add(id);
            lbSelectedSubject.Items.Add(lbSubject.Items[index]);
        }
    }
}
private void LbSelectedSubject_MouseDoubleClick(object sender, MouseEventArgs e)
{
    int index = lbSelectedSubject.IndexFromPoint(e.Location);
    if (index != ListBox.NoMatches)
    {
        selectedValueSubject.Remove((int)lbSelectedSubject.SelectedValue);
        lbSelectedSubject.Items.RemoveAt(index);
    }
}
private bool IsNotConstrain(int id, int[] keys)
{
    bool result = true;
    foreach(int key in keys)
    {
        if (key == id)
        {
            result = false;
            break;
        }
    }
    return result;
}
The addition is correct. In the sense that the person creates and displays the Title. The problem is the reverse process. Remove from lbSelectedSubject. A string in LbSelectedSubject_MouseDoubleClick throws an exception:
lbSelectedSubject.SelectedValue
System.NullReferenceException: "object Reference not pointing to object instance." System.Windows.Forms.ListControl.SelectedValue.get returned null.
This lbSelectedSubject.Items contains the correct item and settings for Display and Value. SelectedItem also normally, not null.
The same item in the list lbSubject contains the correct value Value, not null.
Why after adding in the lbSelectedSubject through the line
lbSelectedSubject.Items.Add(lbSubject.Items[index]);
It turns out that SelectedValue does not work? Under other equal conditions lbSubject.
UPDATE It is not duplicate.





