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?
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; } } } }
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
break;
case "C":
case "D":
Thanks Georgi, I will give that a try when I have a moment today. By the way I like your avatar. Is that an SU-33? It's got to be a member of the Flanker family.