Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: CheckListBox, Selecting (checking) items by code (c#, manually)

$
0
0
Try using "searchDirectoriesListBox.SelectedItems.Add( cbi )" to add an item in the SelectedItems collection of the CheckListBox. To make sure the SelectedItems is set, try do do it in a Loaded callback.
public MyView()
    {
      InitializeComponent();
      
      this.Loaded += new System.Windows.RoutedEventHandler( MyView_Loaded );
    }

void MyView_Loaded( object sender, System.Windows.RoutedEventArgs e )
    {
        foreach (string dir in searchDirs)
       {
        // Trying to make them all checked as I add them
        CheckBoxItem cbi = new CheckBoxItem(id, dir, true);
        searchDirectoriesListBox.SelectedItems.Add(cbi);
        id++;
        }
    }

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>