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
30
How to set cell and header check boxes to default state?
posted

Hello,

I would like to add check boxes column to my grid. The list that I pull for the database does not contain boolean column, I would like to add it on the fly. Here is the code from my testing project where I am trying to achieve this:


using Infragistics.Win.UltraWinGrid;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace UITests
{
    public partial class Form1 : Form
    {
        const string IsChecked = "IsChecked";
        public Form1()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var isChecked = ultraGrid1.DisplayLayout.Bands[0]
                .Columns.Add(IsChecked, string.Empty);

            isChecked.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;
            isChecked.Header.CheckBoxVisibility = HeaderCheckBoxVisibility.Always;
            isChecked.DefaultCellValue = Infragistics.Win.DefaultableBoolean.False;

            ultraGrid1.DataSource = Data;
        }

        private List<TestItem> Data
        {
            get
            {
                var data = new List<TestItem>();
                for (var i = 0; i < 3; ++i)
                {
                    data.Add(new TestItem()
                    {
                        ID = i.ToString(),
                        Name = "name" + i,
                        Description = "description" + i
                    });
                }

                return data;
            }
        }
    }

    public class TestItem
    {
        public string ID { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
    }
}

I want all row and header checkboxes to be unchecked by default, but they are in an indeterminate state: