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
4695
AllowAddNew --> Column No Edit
posted

Dear all,

I have the ultragrid with allow add new to be true and I have set the columns to be no edit except the last one. But this change apply to the addnewRow. Is it possible not applying to the addnewRow which I want to allow editing??

  • 469350
    Offline posted

    You can tell a single cell to ignore the activation on the column or cell and only look at it's own Activation property (which defaults to AllowEdit).

    So to achieve what you want here, you can do something like this:


            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                UltraGridLayout layout = e.Layout;
                UltraGridBand band = layout.Bands[0];
                UltraGridOverride ov = layout.Override;

                ov.AllowAddNew = AllowAddNew.TemplateOnTop;
                for (int i = 0; i < band.Columns.Count -1; i++)           
                {
                    UltraGridColumn column = band.Columns[i];
                    column.CellActivation = Activation.NoEdit;
                }
            }
            private void ultraGrid1_InitializeTemplateAddRow(object sender, InitializeTemplateAddRowEventArgs e)
            {
                this.AdjustRowUpdating(e.TemplateAddRow);
            }

            private void ultraGrid1_AfterRowUpdate(object sender, RowEventArgs e)
            {
                this.AdjustRowUpdating(e.Row);
            }

            private void AdjustRowUpdating(UltraGridRow row)
            {
                bool allowUpdate = row.IsAddRow || row.IsTemplateAddRow;
                foreach (UltraGridCell cell in row.Cells)
                {
                    cell.IgnoreRowColActivation = allowUpdate;
                }
            }