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
285
AfterCellUpdate will not fire when i try to set the same value that is already present in the cell
posted

Hi,

I am trying to update a readonly column when user modifies value in another column. Ingragistics identifies that if the cell value is same then it does not fire the AfterCellUpdate event. Sample code is pasted below.

In the below example after i click button1 , i load the grid's datasource. Then i go to EmpDayHours and modify the value from 5 to 8 and tabout of the cell. This will hit the AfterCellUpdate event and inside switch it will first match nCol = 3 (because we edited EmpDayHours) this will go to SetEmpSalary and setting value will once again trigger the AfterCellUpdate , now this time in the switch it will go to default and call the SetEmpSalary again but this time we are trying to set the same value and the AfterCellUpdate event wont fire. In my actual code since it does not fire the AfterCellUpdate event at this point some other columns dependent on this column do not get updated. Is there a way to let Infragistics know to fire the event again by making the cell's state dirty or any other way.

Thanks - Keerti

public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable("EmpDataTable");
            dt.Columns.Add(new DataColumn("EmpId" , typeof(string)));
            dt.Columns.Add(new DataColumn("EmpName" , typeof(string)));
            dt.Columns.Add(new DataColumn("EmpSalary" , typeof(float)));
            dt.Columns.Add(new DataColumn("EmpDayHours" , typeof(float)));
            
            //add a row
            DataRow dr = dt.NewRow();

            dr["EmpId"] = "61614";
            dr["EmpName"] = "Keerti";
            dr["EmpSalary"] = 50000;
            dr["EmpDayHours"] = 5;

            dt.Rows.Add(dr);
            ultraGrid1.DataSource = dt;
        }

        private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {

        }

        private void ultraGrid1_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
        {
            int nCol = e.Cell.Column.Index;
            int nRow = e.Cell.Row.Index;
            switch (nCol)
            {
                case 3:
                    SetEmpSalary(nRow , 89000);
                    SetEmpSalary(nRow , 89000);
                    break;
                default:
                    SetEmpSalary(nRow, 89000);
                    break;
            }
        }

        private void SetEmpSalary(int nRow , float salary)
        {
            ultraGrid1.Rows[nRow].Cells["EmpSalary"].Value = salary;
        }

InfragisticsIssueAnalysis.zip
Parents Reply Children