TableView - RowFilter #2377
-
Does the TableView support the DataTable's underlying RowFilter? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Also you will want some try/catch logic when setting var find = new TextField{Width = 10};
find.TextChanged += (_)=>
{
if(find.Text.Length == 0)
{
dt.DefaultView.RowFilter = null;
}
else
{
dt.DefaultView.RowFilter = "There like '%" + find.Text.ToString() +"%'";
}
tv.Table = dt.DefaultView.ToTable();
tv.Update();
};
win.Add(find); |
Beta Was this translation helpful? Give feedback.
RowFilter
is part ofDefaultView
which is not used byTableView
. However you can generate a new table from the view (see code below for example). If you have a very large table though you may not want to do this on every keystroke. If you apply this filter using background threads or async make sure to update the table usingApplication.MainLoop.Invoke
to prevent changing the table during drawing. Also when you activate or right click etc the cells in the filtered table then the indexes will refer to what is currently displayed (not your original table e.g.dt
).Also you will want some try/catch logic when setting
RowFilter
because it gives exceptions on bad syntax which would go badly fo…