Hi, I recently upgraded infragistic from 2007.3 to 2011.2. When using formula to calculate with 'product' and one cell is null, the behaves are different. Below are example code that can be run in both version (just add WinGrid and WinCalcManager controls).When running in 7.3, the 'total-prod' column is 0 and Div is 'Infinity' (In my app, it displayed as 'NaN'). When running in 11.2, the 'total-prod' column is 1000 and div column is '#DIV/0!', Is there any way (setting some properties) that I can get back to old behave since our users get used to that? When using product, the result is not acceptable since one of cell values is null. Thanks.
namespace WinGrid{ public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e) { DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Salary", typeof(int)); dt.Columns.Add("Date", typeof(DateTime)); dt.Columns.Add("age", typeof(int)); dt.Columns.Add("total-multi", typeof(int)); dt.Columns.Add("total-prod", typeof(int)); dt.Columns.Add("div", typeof(int)); dt.Rows.Add(new object[] { 100, "Chris", DBNull.Value, "02/03/2012", 10 }); dt.Rows.Add(new object[] { 101, "Mary", 8489, "05/04/2010", 10 }); dt.Rows.Add(new object[] { 102, "Ajay", 564, "06/05/3022", 10 });
// this.ultraGrid1.DisplayLayout.Bands[0].Columns.Add("UnboundColumn", "Total");
DataColumn[] dc = new DataColumn[1]; dc[0] = dt.Columns["ID"]; dt.PrimaryKey = dc; this.ultraGrid1.DataSource = dt; this.ultraGrid1.DataBind();
}
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { e.Layout.Bands[0].Columns["total-multi"].Nullable = Infragistics.Win.UltraWinGrid.Nullable.Null; e.Layout.Bands[0].Columns["total-multi"].Formula = "[ID]* [Salary]* [age]"; // "product([ID], [Salary], [age])";
e.Layout.Bands[0].Columns["total-prod"].Nullable = Infragistics.Win.UltraWinGrid.Nullable.Null; e.Layout.Bands[0].Columns["total-prod"].Formula = "product([ID], [Salary], [age])";
e.Layout.Bands[0].Columns["div"].Nullable = Infragistics.Win.UltraWinGrid.Nullable.Null; e.Layout.Bands[0].Columns["div"].Formula = "[ID]/[total-multi]";
} }}
Hello ,
Thank you for your feedback, I am glad to hear that this worked for you.
Thank you for using Infragistics Components.
Thanks Hristo. That worked fine. We posted our notes about same time so I didn't see your reply when I added my notes before.
Hello,
Have you tried my suggestion regarding “#DIV/0!” ? Have you ran my sample ? It does what you need, isn't it ?
Please let me know if you have any further questions or if I am missing something.
Thanks Mark. I can change to use multiple instead of product in formula. Our users get used to old way and think this is bug. As for displaying as 'NaN' instead of #DIV/0! when divided by zero, is there any setting that I can use to get back the old way? Thanks.
About “#DIV/0!” you could set resource string which will determine the string displayed in the cell, when UltraCalcManager divides by zero . The exactly resource string which you should change is “Value_UCErrorCode_Div”. on the following links you will find an information about Infragistics ResourceCustomize and how to use it.
http://help.infragistics.com/Help/NetAdvantage/WinForms/2011.2/CLR2.0/html/Win_Assembly_Resource_Strings.html
http://help.infragistics.com/Help/NetAdvantage/WinForms/2011.2/CLR2.0/html/Win_Customizing_Assembly_Resource_Strings.html
http://help.infragistics.com/Help/NetAdvantage/WinForms/2011.2/CLR2.0/html/Shared_Resource_Strings.html
Also based on your code snippet I have implement a small sample in order to demonstrate you how to solve your issue abut “#DIV/0!”.
The second issue regarding “product(value1, value2)” function, the behavior is expected, because “product(value1, value2)” function of UltraCalcManager should behave like “product(value1, value2)” function in Excel, so instead of product you should multiply the values which you are need.
Please let me know if you have any further questions.