How to filter datagridview using custom popup

my user popup control on a datagridview cell double click and populate strings.Add(dataGridView1.Rows[i].Cells[e.ColumnIndex].Value.ToString());in the user element controllistlistbox and one button. how can I filter a datagridview when a button is clicked and checked ListBox1.CheckedItems using bindingSource.filter = string.Format ("LoadName LIKE '{}'",); Thanks

+1
source share
1 answer

I think you need something like this:

var checkedValues = strings.Where(s => IsChecked(s))
                           .Select(s => "'"+s+"%'")
                           .ToArray();
bindingSource.Filter = "LoadName LIKE " + string.Join(" or ",checkedValues);

Where IsChecked()is the fake method, you should replace it with something telling you if the value is marked or not in yours CheckedListBox.

, CheckedListBox - , :
strings.Where(s => IsChecked(s))
:
ceckedListBox.CheckedItems.Cast<string>()

+2

Source: https://habr.com/ru/post/1794047/


All Articles