How customize the parameters for the property with the attribute [CompositeField]
Hi Dapfor Team,
Could you provide the example of code with custom resolving format property (IFormat) for the class with [CompositeField] property.
For example, we have the class which described in topic: http://www.dapfor.com/Feature.aspx?id=composite_objects
How we can use different formating (IFormat) of the column values for each row in the grid?
1st row - double value with 4 digits after comma = 4.5677
2nd row - double value with 6 digits after comma = 4.678931
3rd row - double value with 1 digits after comma = 5.1
Thank you!
-
Hello,
You can do it in the grid.PaintCell routine:
grid.PaintCell += delegate(object sender, PaintCellEventArgs e)
{
if(e.Cell.Column != null && e.Cell.Column.Id == "your column id")
{
switch (e.Cell.Row.ChildIndex) //You can also use e.Cell.Row.VisibleIndex
{
case 0:
e.Text = new DoubleFormat(4).Format(e.Cell.DataField);
break;
case 1:
e.Text = new DoubleFormat(6).Format(e.Cell.DataField);
break;
case 2:
e.Text = new DoubleFormat(1).Format(e.Cell.DataField);
break;
}
}
};To prevent from often DoubleFormat object creation, you can create a pool of formats or use them as members of your control.
Best regards,
The Dapfor Team
0
Please sign in to leave a comment.
Comments
1 comment