jeudi 1 octobre 2015

How to get the state of checkboxes

I want to know the state of my chekcboxes when I check or uncheck them.

I'm creating checkboxes columns according to my DB (one column for one line in my table). I'm using Infragistics 2015. So here's my code to create the columns :

/// <summary>
/// Add columns in table according to the sites stored in DB
/// </summary>
/// <remarks>The action is used to create site column</remarks>
private void AddColumnSites()
{
    const string siteCol = "SITE_COL";

    var addNewSite = new Action<string>(site =>
    {
        var ultraGridBand = this.CVaultGrid.DisplayLayout.Bands[0];

        var gridDataColumn = new UltraDataColumn(site);
        gridDataColumn.DataType = typeof(bool);
        gridDataColumn.Tag = siteCol;
        gridDataColumn.DataType = typeof(bool);
        gridDataColumn.DefaultValue = false;
        gridDataColumn.SubObjectPropChanged += this.OnSubObjectPropChanged;
        this.CVaultDataSource.Band.Columns.AddRange(new object[] {
            gridDataColumn
        });
    });

    for (int i = this.CVaultDataSource.Band.Columns.Count-1; i >= 0 ; i--)
    {
        if (this.CVaultDataSource.Band.Columns[i].Tag == siteCol)
        {
            this.CVaultDataSource.Band.Columns.RemoveAt(i);
        }
    }

    var sitesDB = from sites in this.lSites
                  orderby sites.KEY
                  select  sites.KEY ;

    foreach (var item in sitesDB)
    {
        addNewSite(item);
    }
}

I would like to create a private method to get the state of the checkboxes and returns me the result in a string or a boolean.




Aucun commentaire:

Enregistrer un commentaire