p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   .NET Framework 2.0 (http://p2p.wrox.com/forumdisplay.php?f=141)
-   -   Data filtering (http://p2p.wrox.com/showthread.php?t=98946)

maplecutie May 24th, 2016 07:21 PM

Data filtering
 
how can I create the filter itself and to set filtering conditions using already described IFilter interface. I am using Dapfor .Net grid.

sobort84 May 24th, 2016 07:28 PM

Quote:

Originally Posted by maplecutie (Post 307497)
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();
}
}
}


All times are GMT -4. The time now is 03:00 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.