How to bind Dictionary to ListBox in WinForms

前端 未结 3 1416
旧巷少年郎
旧巷少年郎 2020-11-30 04:25

It is possible to bind a Dictionary to a Listbox, keeping in sync between the Listbox and the member property?

3条回答
  •  独厮守ぢ
    2020-11-30 04:42

            label1.Text= listBox1.SelectedIndex.ToString();
    
            if ( listBox1.SelectedItem is KeyValuePair)
            {
    
                var temp1 = (KeyValuePair)listBox1.SelectedItem;
                label3.Text = temp1.Key.ToString();
                label4.Text = temp1.Value.ToString();
    
    
            }
    

提交回复
热议问题