Esempio n. 1
0
        private void spreadsheetControl_CustomCellEdit(object sender, DevExpress.XtraSpreadsheet.SpreadsheetCustomCellEditEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                RepositoryItemTextEdit repository = new RepositoryItemTextEdit();
                repository.AutoHeight  = false;
                repository.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;

                Style  thisCellsStyle     = e.Cell.Style;
                string thisCellsFormat    = thisCellsStyle.NumberFormat;
                string thisCellsStyleName = thisCellsStyle.Name;
                thisCellsFormat = e.Cell.NumberFormat;
                bool thisCellIsLocked = e.Cell.Protection.Locked;
                IList <DevExpress.Spreadsheet.Comment> comments = spreadsheetControl.ActiveWorksheet.Comments.GetComments(spreadsheetControl.ActiveCell);
                string thisCellsNote = comments[0].Text; // hardcoding '0' only works because there is only one ActiveCell

                if (thisCellsFormat == "")
                {
                    repository.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.None;
                }
                else
                {
                    repository.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
                    repository.Mask.EditMask = thisCellsFormat;
                }
                e.RepositoryItem = repository;
            }
        }
        private void spreadsheetControl1_CustomCellEdit(object sender, DevExpress.XtraSpreadsheet.SpreadsheetCustomCellEditEventArgs e)
        {
            // Specify a type of the custom editor assigned to cells of the "Quantity" table column.
            // To identify the custom editor, use a value of ValueObject associated with it.
            if (e.ValueObject.IsText && e.ValueObject.TextValue == "MySpinEdit")
            {
                // Create a repository item corresponding to a SpinEdit control and specify its settings.
                RepositoryItemSpinEdit repository = new RepositoryItemSpinEdit();
                repository.AutoHeight  = false;
                repository.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;

                repository.MinValue     = 1;
                repository.MaxValue     = 1000;
                repository.IsFloatValue = false;
                // Assign the SpinEdit editor to a cell.
                e.RepositoryItem = repository;
            }
        }