Ejemplo n.º 1
0
 private void OnTwoColorsCustomClick(object sender, EventArgs e)
 {
     CustomFormatRule fm = new CustomFormatRule(EnumConditionalFormatType.TwoColorsRange);
     fm.ShowDialog();
     if (fm.DialogResult == DialogResult.OK)
     {
         OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected);
         ConditionalFormatting format = formatConditions.Where(x => x.ColumnName == col.Name).FirstOrDefault();
         if (format == null)
         {
             ConditionalFormatting newformat = new Formatting.ConditionalFormatting(col.DataGridViewColumn.Name, EnumConditionalFormatType.TwoColorsRange, new TwoColorsParams(fm.colMin, fm.colMax));
             formatConditions.Add(newformat);
         }
         else
         {
             format.FormatType = EnumConditionalFormatType.TwoColorsRange;
             format.FormatParams = new TwoColorsParams(fm.colMin, fm.colMax);
         }
         Fill();
     }
     fm.Dispose();
 }
        /// <summary>
        /// Loads the default configuration.
        /// </summary>
        /// <param name="Grid">The grid.</param>
        private void LoadDefaultConfiguration(JDHSoftware.Krypton.Toolkit.KryptonOutlookGrid.KryptonOutlookGrid Grid)
        {
            Grid.ClearEverything();
            Grid.GroupBox.Visible = true;
            Grid.HideColumnOnGrouping = false;

            Grid.FillMode = FillMode.GroupsAndNodes; //treemode enabled;
            Grid.ShowLines = true;

            activeColumns = new SandBoxGridColumn[] {
                SandBoxGridColumn.ColumnCustomerID,
                SandBoxGridColumn.ColumnCustomerName,
                SandBoxGridColumn.ColumnAddress,
                SandBoxGridColumn.ColumnCity,
                SandBoxGridColumn.ColumnCountry,
                SandBoxGridColumn.ColumnOrderDate,
                SandBoxGridColumn.ColumnProduct,
                SandBoxGridColumn.ColumnPrice,
                SandBoxGridColumn.SatisfactionColumn,
                SandBoxGridColumn.ColumnToken
            };

            DataGridViewColumn[] columnsToAdd = new DataGridViewColumn[10]
            {
            SetupColumn(SandBoxGridColumn.ColumnCustomerID),
            SetupColumn(SandBoxGridColumn.ColumnCustomerName),
            SetupColumn(SandBoxGridColumn.ColumnAddress),
            SetupColumn(SandBoxGridColumn.ColumnCity),
            SetupColumn(SandBoxGridColumn.ColumnCountry),
            SetupColumn(SandBoxGridColumn.ColumnOrderDate),
            SetupColumn(SandBoxGridColumn.ColumnProduct),
            SetupColumn(SandBoxGridColumn.ColumnPrice),
            SetupColumn(SandBoxGridColumn.SatisfactionColumn),
            SetupColumn(SandBoxGridColumn.ColumnToken)
            };
            Grid.Columns.AddRange(columnsToAdd);

            //Define the columns for a possible grouping
            Grid.AddInternalColumn(columnsToAdd[0], new OutlookGridDefaultGroup(null), SortOrder.None, -1, -1);
            Grid.AddInternalColumn(columnsToAdd[1], new OutlookGridAlphabeticGroup(null), SortOrder.None, -1, -1);
            Grid.AddInternalColumn(columnsToAdd[2], new OutlookGridDefaultGroup(null), SortOrder.None, -1, -1);
            Grid.AddInternalColumn(columnsToAdd[3], new OutlookGridDefaultGroup(null), SortOrder.None, -1, -1);
            Grid.AddInternalColumn(columnsToAdd[4], new OutlookGridDefaultGroup(null), SortOrder.None, -1, -1);
            Grid.AddInternalColumn(columnsToAdd[5], new OutlookGridDateTimeGroup(null), SortOrder.None, -1, -1);
            Grid.AddInternalColumn(columnsToAdd[6], new OutlookGridDefaultGroup(null) { OneItemText = "1 product", XXXItemsText = " products" }, SortOrder.None, -1, -1);
            Grid.AddInternalColumn(columnsToAdd[7], new OutlookGridPriceGroup(null), SortOrder.None, -1, -1);
            Grid.AddInternalColumn(columnsToAdd[8], new OutlookGridDefaultGroup(null), SortOrder.None, -1, -1);
            Grid.AddInternalColumn(columnsToAdd[9], new OutlookGridDefaultGroup(null), SortOrder.None, -1, -1);

            //Add a default conditionnal formatting
            ConditionalFormatting cond = new ConditionalFormatting();
            cond.ColumnName = SandBoxGridColumn.ColumnPrice.ToString();
            cond.FormatType = EnumConditionalFormatType.TwoColorsRange;
            cond.FormatParams = new TwoColorsParams(Color.White, Color.FromArgb(255, 255, 58, 61));
            Grid.ConditionalFormatting.Add(cond);
        }