Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
505
Problems with formula on bound column
posted

According to the help formulas on bound columns are supported but I can't get it to work. http://help.infragistics.com/Help/NetAdvantage/WinForms/2011.1/CLR2.0/HTML/WinCalcManager_Formula_and_Reference_Guide.html

When I assign a formula to a bound column I get strange behaviour. When the source cell is changed via the underlying DataTable it's value displayed in the grid doesn't update - but it does redraw when the mouse hovers over the cell! But also the calculated formula value doesn't update at all. If I add an unbound column with the same formula this also doesn't update when the source cell changes. But if I remove the formula on the bound column the cell updates properly and the unbound column shows the calculated value. Note that if the user modifies the value in the cell directly then both the bound and unbound cells update correctly, so it's only when the update is through the datasource.

I really need to be able to use a bound column as I need a 1-1 mapping between the columns in the grid and the underlying datatable. I'm using infragistics v9.2

This is simply demonstrated by the following code, just drop it into a forms constructor. It creates a grid with a bound source column, a bound formula column and one unbound formula column. The calculated value depends on the first cell. It also adds a button that toggles the value of the first cell which should change the formula. Commenting out the line that assigns the formula to bound column 1 shows the unbound cell changing correctly.

Thanks, Martin

            UltraGrid grid = new UltraGrid { Name = "grid", Dock = DockStyle.Fill };
            grid.CalcManager = new UltraCalcManager();
            Controls.Add(grid);
            
            DataTable dt = new DataTable();
            dt.Columns.Add("col1", typeof(object));
            dt.Columns.Add("col2", typeof(object));
            dt.Rows.Add(new object[] { DBNull.Value, "" });

            grid.DataSource = dt;
            grid.Rows.Band.Columns.Add("unbound");
            grid.Rows.Band.Columns[1].Formula = "IF([col1] = \"\", \"Blank\", \"Value\")";
            grid.Rows.Band.Columns[2].Formula = "IF([col1] = \"\", \"Blank\", \"Value\")";

            UltraButton btn = new UltraButton() { Dock = DockStyle.Top, Text = "Toggle" };
            Controls.Add(btn);
            btn.Click += (s, e) => dt.Rows[0][0] = dt.Rows[0][0] == DBNull.Value ? (object)1.0 : DBNull.Value;

Parents Reply Children
No Data