how can I create the filter itself and to set filtering conditions using already described IFilter interface. I am using Dapfor .Net grid.
Loading
how can I create the filter itself and to set filtering conditions using already described IFilter interface. I am using Dapfor .Net grid.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
pedro latorPosted May 30, 2016, 1:26 PM
a brilliant question!. The following code should be of help.
public class RatingEditor : UITypeEditorEx
{
public overridebool GetPaintCellSupported()
{
//The cellshould be repainted in the editor
return true;
}
public overridevoid PaintCell(PaintCellEventArgs e)
{
//Do basicpainting without text
e.Text =string.Empty;
e.PaintAll();
e.Handled =true;
//Draw thestars over the cell
Rectanglebounds = e.Cell.VirtualBounds;
bounds.Width =Resources.star_grey.Width;
for (int i = 0;i < 5; i++)
{
//Selectimage
if (e.Cell.Value!= null && e.Cell.Value is int)
{
intcurRating = (int) e.Cell.Value;
Imageimage = i >= curRating ? Resources.star_grey : Resources.star_yellow;
e.Graphics.DrawImage(image, bounds);
bounds.X += bounds.Width;
}
}
}
public overrideStopEditReason EditCell(IGridEditorService service, Cell cell, StartEditReasonreason)
{
//Edit the cellif the user has clicked on the cell with the left button
if (cell.Row !=null && Equals(StartEditReason.LButtonClick, reason))
{
Point pt =cell.Row.Grid.PointToClient(Cursor.Position);
Rectanglebounds = cell.VirtualBounds;
intimageWidth = Resources.star_grey.Width;
if(bounds.Contains(pt) && imageWidth > 0)
{
//Set anew rating to the data object
cell.Value = ((pt.X - bounds.X)/imageWidth) + 1;
cell.Invalidate();
}
}
returnStopEditReason.UserStop;
}
}