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
630
Prevent User From Adding a Row to a Band in the Grid
posted

We have a situation where we have a grid that has three bands. If the user checks a box on the second band we do not want the user to be able to add a record to the third band. What would be the best way to accomplish that?

Parents
  • 53790
    posted

    Hello James,

    Maybe you could achieve desired behavior using "CheckBoxVisibility" and AllowAddNew properties. Please take a look at the attached sample for more details. If you have any questions, do not hesitate to write us

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Linq;

    using System.Text;

    using System.Windows.Forms;

     

    namespace UltraGridWithThreeBandsAddRows

    {

        public partial class Form1 : Form

        {

            public Form1()

            {

                InitializeComponent();

     

                ultraGrid1.DisplayLayout.Bands[0].Columns["A"].Header.CheckBoxVisibility = Infragistics.Win.UltraWinGrid.HeaderCheckBoxVisibility.Always;

                ultraGrid1.DisplayLayout.Bands[1].Columns["C"].Header.CheckBoxVisibility = Infragistics.Win.UltraWinGrid.HeaderCheckBoxVisibility.Always;

                ultraGrid1.DisplayLayout.Bands[2].Columns["E"].Header.CheckBoxVisibility = Infragistics.Win.UltraWinGrid.HeaderCheckBoxVisibility.Always;

     

     

                ultraGrid1.DisplayLayout.Bands[0].Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.TemplateOnBottom;

                ultraGrid1.DisplayLayout.Bands[1].Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.TemplateOnBottom;

                ultraGrid1.DisplayLayout.Bands[2].Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.TemplateOnBottom;

            }

     

            private void ultraGrid1_BeforeHeaderCheckStateChanged(object sender, Infragistics.Win.UltraWinGrid.BeforeHeaderCheckStateChangedEventArgs e)

            {

                switch (e.Column.Key)

                {

                    case "A":

                        if (e.CurrentCheckState != CheckState.Checked)

                        {

                            ultraGrid1.DisplayLayout.Bands[1].Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No;

                            ultraGrid1.DisplayLayout.Bands[2].Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No;

                        }

                        else

                        {

                            ultraGrid1.DisplayLayout.Bands[1].Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.TemplateOnBottom;

                            ultraGrid1.DisplayLayout.Bands[2].Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.TemplateOnBottom;

                        }

     

                        break;

     

                    case "C":

                        if (e.CurrentCheckState != CheckState.Checked)

                        {

                            ultraGrid1.DisplayLayout.Bands[2].Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No;

                        }

                        else

                        {

                            ultraGrid1.DisplayLayout.Bands[2].Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.TemplateOnBottom;

                        }

                        break;

     

                    case "D":

                        break;

               

                }

            }

        }

    }

     

     

    UltraGridWithThreeBandsAddRows.zip
Reply Children
No Data