Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

storing list box contents in array

$
0
0

I have a listbox displaying gifs (pulled from a database).

I would like to be able to store the listbox's contents into an array. I tried assigning the source to an array, but I'm getting the error that cannot implicitly convert type System.Data.DataView to the array.

How can I solve this?

privatevoidBtn_Click(object sender,RoutedEventArgs e){SQLiteConnection sqliteCon =newSQLiteConnection(dbConnectionString);

      sqliteCon.Open();stringSelectionQuery="SELECT gif FROM myTable WHERE Style = 'Jump'";SQLiteDataAdapter adapter =newSQLiteDataAdapter(SelectionQuery, sqliteCon);DataTable dt =newDataTable();
      adapter.Fill(dt);DataView source = myListBox.ItemsSourceasDataView;foreach(DataRow dr in dt.Rows){
         source.Table.ImportRow(dr);}

      myListBox.ItemsSource=null;
      myListBox.ItemsSource= source;}


Viewing all articles
Browse latest Browse all 18858

Trending Articles



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