Aspose.Cells.GridWeb.Examples.CSharp.Cells.AddDropdownListValidation.btnAddDropDownListValidation_Click C# (CSharp) Method

btnAddDropDownListValidation_Click() protected method

protected btnAddDropDownListValidation_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        protected void btnAddDropDownListValidation_Click(object sender, EventArgs e)
        {
            // ExStart:AddDropDownListValidation
            // Accessing the cells collection of the worksheet that is currently active
            GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];

            // Access "B1" cell and add some text
            GridCell cell = sheet.Cells[0, 1];
            cell.PutValue("Select Degree:");

            // Accessing "C1" cell
            cell = sheet.Cells[0, 2];

            // Creating DropDownList validation for the "C1" cell
            var validation = cell.CreateValidation(GridValidationType.DropDownList, true);
                        
            // Adding values to DropDownList validation
            var values = new System.Collections.Specialized.StringCollection();
            values.Add("Bachelor");
            values.Add("Master");
            values.Add("Doctor");
            validation.ValueList = values;
            // ExEnd:AddDropDownListValidation
        }
    }