github twitter email rss
0001 Jun 1
One minute read

WinForms, Windows Forms

WPF in WinForms

animation min max

WinForms MVVM

ICommand winforms

ListBox tips

Track focused element

BindingList<string> list;
listBox.DataSource = list;
listBox.SelectionMode = SelectionMode.One;
listBox.SelectedValueChanged += delegate
        var value = listBox.SelectedItem;
// When changing binding list SelectedValueChanged will not raise so need to track focused element
list.ListChanged += delegate 
        var value = listBox.SelectedItem;

ComboBox tips

Check for selectin changes

comboBox.SelectedValueChanged += delegate
        var value = uiPlanSelector.SelectedItem;

Populate read only

var list = List<string>();
comboBox.DataSource = list

Populate editable source

// source should implement INotifyPropertyChanged and raise event when change ValuesProperty
comboBox.DataBindings.Add("DataSource", source, "ValuesProperty");

WinForms Checked List Box

Using CheckedListBox

multiple selection is not supported
datasource etc not supported

Using ListView

allows for multiple selection

  • CheckBoxes to true
  • HeaderStyle to None
  • View to Details

Back to posts

comments powered by Disqus