private void AddColumnToColumnsGrid(Column column)
        {
            SlyceTreeGridItem gridItem = new SlyceTreeGridItem();
            gridItem.Tag = column;
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.Name));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.Description));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.IsNullable));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.OriginalDataType == null ? null : column.OriginalDataType.ToLower()));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.Default));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.OrdinalPosition));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.Size));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.SizeIsMax));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.Precision));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.Scale));

            foreach (IKey key in Table.Keys)
            {
                SlyceTreeGridCellItem item = new SlyceTreeGridCellItem(key.Columns.Contains(column));
                item.Enabled = true;// column.InPrimaryKey;
                gridItem.SubItems.Add(item);
            }

            slyceGrid1.Items.Add(gridItem);
        }
 private SlyceTreeGridCellItem CreateNewNullableCell(ArchAngel.Providers.EntityModel.Model.EntityLayer.Property property, object value, ApplicableOptions options)
 {
     ApplicableOptions applicableOptions = ValidationOptions.GetApplicableValidationOptionsForType(property.Type);
     SlyceTreeGridCellItem cell = new SlyceTreeGridCellItem(value, (applicableOptions & options) != options);
     cell.IsNullable = true;
     return cell;
 }
 private SlyceTreeGridCellItem CreateNewNullableCell(ComponentPropertyImpl property, object value, ApplicableOptions options)
 {
     ApplicableOptions applicableOptions = ValidationOptions.GetApplicableValidationOptionsForType(property.Type);
     SlyceTreeGridCellItem cell = new SlyceTreeGridCellItem(value, (applicableOptions & options) != options);
     cell.IsNullable = true;
     return cell;
 }
Esempio n. 4
0
        private void AddItemToGrid(SlyceTreeGridItem item, bool updateLastRow)
        {
            List <object> subItemValues = new List <object>();

            if (ShowDeleteColumn)
            {
                subItemValues.Add(DeleteImage);
            }

            List <int> cellsToIgnore  = new List <int>();
            List <int> cellsToDisable = new List <int>();

            for (int subItemCounter = 0; subItemCounter < item.SubItems.Count; subItemCounter++)
            {
                SlyceTreeGridCellItem subItem = item.SubItems[subItemCounter];

                //if (subItem.IsNullable)
                //{
                //    subItemValues.Add(subItem.HasValue);

                //    if (subItem.Ignore)
                //        cellsToIgnore.Add(subItemValues.Count - 1);
                //}
                subItemValues.Add(subItem.Value);

                if (subItem.Ignore)
                {
                    cellsToIgnore.Add(subItemValues.Count - 1);
                }

                if (!subItem.Enabled)
                {
                    cellsToDisable.Add(subItemValues.Count - 1);
                }

                //else if (subItem.IsNullable && !subItem.HasValue)
                //    cellsToDisable.Add(subItemValues.Count - 1);
            }
            int i;

            if (updateLastRow)
            {
                i = dataGridViewX1.Rows.Count - 2;
                dataGridViewX1.Rows[i].SetValues(subItemValues.ToArray());
            }
            else
            {
                i = dataGridViewX1.Rows.Add(subItemValues.ToArray());
            }

            foreach (int cellIndex in cellsToIgnore)
            {
                if (cellIndex >= dataGridViewX1.Rows[i].Cells.Count)
                {
                    continue;
                }

                object ccc = dataGridViewX1.Rows[i].Cells[cellIndex];

                if (ccc is DataGridViewTextBoxCellEx)
                {
                    ((DataGridViewTextBoxCellEx)ccc).Enabled = false;
                }
                else if (ccc is DataGridViewComboBoxCellEx)
                {
                    ((DataGridViewComboBoxCellEx)ccc).Enabled = false;
                }
                else
                {
                    dataGridViewX1.Rows[i].Cells[cellIndex].ReadOnly        = true;
                    dataGridViewX1.Rows[i].Cells[cellIndex].Style.BackColor = Color.Pink;
                    //dataGridViewX1.Rows[i].Cells[cellIndex - 1].Style.BackColor = Color.Pink;
                }
            }
            foreach (int cellIndex in cellsToDisable)
            {
                dataGridViewX1.Rows[i].Cells[cellIndex].ReadOnly = true;
                //dataGridViewX1.Rows[i].Cells[cellIndex].Style.BackColor = Color.LightGray;
                //dataGridViewX1.Rows[i].Cells[cellIndex - 1].Style.BackColor = Color.LightGray;
            }
            for (int rowCounter = 0; rowCounter < dataGridViewX1.Rows.Count; rowCounter++)
            {
                dataGridViewX1.Rows[rowCounter].DefaultCellStyle.BackColor = rowCounter % 2 == 0 ? BackColor : AlternatingBackColor;
            }

            Tags.Add(item.Tag);
        }