Thread: Data filtering
View Single Post
  #2 (permalink)  
Old May 24th, 2016, 07:28 PM
sobort84 sobort84 is offline
Registered User
Points: 6, Level: 1
Points: 6, Level: 1 Points: 6, Level: 1 Points: 6, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2016
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by maplecutie View Post
how can I create the filter itself and to set filtering conditions using already described IFilter interface. I am using Dapfor .Net grid.
//User control for editing a filter.
public partial class CustomFilterControl : UserControl
{
private IWindowsFormsEditorService _service;
private CustomFilter _filterEditor;
private IFilter _currentFilter;

public CustomFilterControl()
{
InitializeComponent();
}

public IFilter CurrentFilter
{
get { return _currentFilter; }
}

public void EditFilter(IWindowsFormsEditorService service, CustomFilter filterEditor)
{
if (service != null)
{
//Display the control
_filterEditor = filterEditor;
_service = service;
service.DropDownControl(this);
}
}

//Called when the user clicks on the 'Ok' button
private void buttonOk_Click(object sender, EventArgs e)
{
if (_service != null)
{
//Create a filter and keep it in the _currentFilter variable
double minValue = (double)minValueCtrl.Value;
double maxValue = (double)maxValueCtrl.Value;
_currentFilter = new Ui.Filter(delegate(Row row)
{
double price = (double) row["Price"].Value;
if (minValue > 0 && price < minValue)
{
//filter the row, if the value less than the minValue.
return true;
}
if (maxValue > 0 && price > maxValue)
{
//filter the row, if the value less than the minValue.
return true;
}
return false;
});

//Close the dropdown control
_service.CloseDropDown();
}
}
}
Reply With Quote
The Following User Says Thank You to sobort84 For This Useful Post: