private void Form2_Shown(object sender, EventArgs e) { string categories = null, languages = null; listView1.Items.Clear(); for (int i = 0; i < checkedListBox1.Items.Count; i++) { if (checkedListBox1.GetItemCheckState(i) == CheckState.Checked) { categories = categories + checkedListBox1.Items[i].ToString() + ";"; } if (checkedListBox2.GetItemCheckState(i) == CheckState.Checked) { languages = languages + checkedListBox2.Items[i].ToString() + ";"; } } List <string> books = new List <string>(); List <string> authors = new List <string>(); List <string> Lents = new List <string>(); List <string> category = new List <string>(); List <string> language = new List <string>(); books = connection.searchBookNames(null, false, categories, languages); authors = connection.searchAuthor(null, false, categories, languages); Lents = connection.searchLents(null, false, categories, languages); category = connection.searchCategory(null, false, categories, languages); language = connection.searchLanguage(null, false, categories, languages); for (int i = 0; i < books.Count; i++) { ListViewItem item = new ListViewItem(books[i]); item.SubItems.Add(authors[i]); item.SubItems.Add(Lents[i]); item.SubItems.Add(category[i]); item.SubItems.Add(language[i]); listView1.Items.Add(item); } }