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.
Thanks for the feedback. If you have any questions, do not hesitate to write us
Regards
Sorry for getting back to you late. Yes I did and it works for me. Thank you!
Have you been able to resolve your issue ? Did you have a time to take a look at the attached sample. Please let me know if you have any questions
If you have any questions regarding attached sample, please do not hesitate to write us.
JamesPearson said:By the way I like your avatar. Is that an SU-33?
Thanks ! It is Su-35 - http://sukhoi.org/eng/gallery/?gallery_id=3&cur_gallery_id=1100
and it is one of my special flights: http://www.youtube.com/watch?v=BdGg1KZI3-Q