/// <summary>
        /// Export to PDF on Button click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Exportbutton_Click(object sender, EventArgs e)
        {
            var converter = new GridPDFConverter();
            var lowest    = 0;

            //Adding PageBreaks to a list.
            var rows = new List <int> {
                30, 63, 90, 130, 150
            };

            var pdfDocument = new PdfDocument();

            pdfDocument.Save("Sample.pdf");
            foreach (var rownumber in rows)
            {
                var pdf        = new PdfDocument();
                var maximumRow = rownumber;
                converter.ExportToPdf(pdf, gridControl1, GridRangeInfo.Rows(lowest, maximumRow));
                var stream = new MemoryStream();
                pdf.Save(stream);
                var loadedDocument = new PdfLoadedDocument("Sample.pdf");
                loadedDocument =
                    PdfDocumentBase.Merge(loadedDocument, new PdfLoadedDocument(stream)) as PdfLoadedDocument;
                loadedDocument.Save("Sample.pdf");
                loadedDocument.Close(true);
                stream.Dispose();
                lowest = maximumRow + 1;
            }
            var loadedDocument1 = new PdfLoadedDocument("Sample.pdf");

            loadedDocument1.Pages.RemoveAt(0);
            loadedDocument1.Save("Sample.pdf");
            Process.Start("Sample.pdf");
        }
Beispiel #2
0
        /// <summary>
        /// Setting Grid control Properties
        /// </summary>
        private void GridSettings()
        {
            DataSet ds = new DataSet();

            ReadXml(ds, @"..\..\..\..\..\..\Common\Data\Expand.xml");
            int rowCount = gridControl1.RowCount = ds.Tables[1].Rows.Count;
            int colCount = gridControl1.ColCount = ds.Tables[1].Columns.Count;

            this.gridControl1.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, colCount), ds.Tables[1]);
            this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, rowCount - 1, colCount), ds.Tables[1]);
            this.tabBarPage1.Text = ds.Tables[1].TableName;
            //this.gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Rows(1, rowCount - 1));
            this.gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Rows(0, colCount - 1));

            int rowCount1 = ds.Tables[2].Rows.Count;
            int colCount1 = ds.Tables[2].Columns.Count;

            this.gridControl2.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, colCount1), ds.Tables[2]);
            this.gridControl2.PopulateValues(GridRangeInfo.Cells(1, 1, rowCount1 - 1, colCount1), ds.Tables[2]);
            this.tabBarPage2.Text = ds.Tables[2].TableName;
            //this.gridControl2.RowHeights.ResizeToFit(GridRangeInfo.Rows(1, rowCount1 - 1));
            this.gridControl2.ColWidths.ResizeToFit(GridRangeInfo.Rows(0, colCount1 - 1));

            int rowCount2 = ds.Tables[3].Rows.Count;
            int colCount2 = ds.Tables[3].Columns.Count;

            this.gridControl3.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, colCount2), ds.Tables[3]);
            this.gridControl3.PopulateValues(GridRangeInfo.Cells(1, 1, rowCount2 - 1, colCount2), ds.Tables[3]);
            this.tabBarPage3.Text = ds.Tables[3].TableName;
            //this.gridControl3.RowHeights.ResizeToFit(GridRangeInfo.Rows(1, rowCount2 - 1));
            this.gridControl3.ColWidths.ResizeToFit(GridRangeInfo.Rows(0, colCount2 - 1));

            this.gridControl1.Model.Options.DisplayEmptyColumns = true;
            this.gridControl1.Model.Options.DisplayEmptyRows    = true;
        }
Beispiel #3
0
        private void SetRowHeight_Click(object sender, RoutedEventArgs e)
        {
            int    start  = 0;
            int    end    = 0;
            double height = 0;

            if (int.TryParse(sRange.Text, out start) && int.TryParse(eRange.Text, out end) && Double.TryParse(HeightWidth.Text, out height))
            {
                if (start < 1 || end < 1 || (start + (end - start)) > cellGrid.RowCount - 1)
                {
                    ShowErrorMessage("Enter valid range");
                }
                else if (end < start)
                {
                    ShowErrorMessage("Enter end index greater than start index");
                }
                else if (height < 1 || height > 409)
                {
                    ShowErrorMessage("Row Height must be between 0 and 409");
                }
                else
                {
                    cellGrid.RowHeights.SetRange(start, end, height);
                    cellGrid.InvalidateCell(GridRangeInfo.Rows(start, end));
                }
            }
            else
            {
                ShowErrorMessage("Enter a valid range and value");
            }
            cellGrid.Focus(FocusState.Programmatic);
        }
Beispiel #4
0
        private void UnHideRows_Click(object sender, RoutedEventArgs e)
        {
            int sRange = 0;
            int eRange = 0;

            if (int.TryParse(startRange.Text, out sRange) && int.TryParse(endRange.Text, out eRange))
            {
                if (sRange < 1 || eRange < 1 || (sRange + (eRange - sRange)) > cellGrid.ColumnCount - 1)
                {
                    ShowErrorMessage("Enter valid start range and end range");
                }
                else if (eRange < sRange)
                {
                    ShowErrorMessage("Enter end range greater than start range");
                }
                else
                {
                    cellGrid.RowHeights.SetHidden(sRange, eRange, false);
                    cellGrid.InvalidateCell(GridRangeInfo.Rows(sRange, eRange));
                }
            }
            else
            {
                ShowErrorMessage("Enter a valid range...");
            }
            cellGrid.Focus(FocusState.Programmatic);
        }
Beispiel #5
0
        void GridSettings()
        {
            comboTable = this.GetTheComboTable();
            gridTable  = this.GetTheGridTable();
            this.gridGroupingControl1.DataSource = this.GetTheGridTable();
            gridGroupingControl1.TopLevelGroupOptions.ShowFilterBar = true;
            gridGroupingControl1.TopLevelGroupOptions.ShowAddNewRecordBeforeDetails = false;
            GridTableCellStyleInfo ggcStyle = gridGroupingControl1.TableDescriptor.Columns["Customers"].Appearance.AnyRecordFieldCell;

            ggcStyle.CellType      = "ComboBox";
            ggcStyle.DataSource    = this.comboTable;
            ggcStyle.ValueMember   = "CustomerID";
            ggcStyle.DisplayMember = "CustomerName";
            this.gGCFilter         = new GroupingGridFilterBarExt();

            this.gridGroupingControl1.TableControl.DpiAware = true;
            gridGroupingControl1.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Rows(1, 10));
            gridGroupingControl1.TableModel.ColWidths[2] = 150;
            gridGroupingControl1.QueryCellStyleInfo     += new GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo);

            this.gridGroupingControl1.GridVisualStyles = GridVisualStyles.Metro;
            this.BackColor = Color.White;
            this.propertyGrid1.BackColor      = Color.White;
            this.propertyGrid1.SelectedObject = this.gridGroupingControl1;
            this.gridGroupingControl1.AllowProportionalColumnSizing     = true;
            this.gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended;

            //Navigate to other control using tabkey navigation
            this.gridGroupingControl1.WantTabKey = false;

            #region HeaderText
            foreach (GridColumnDescriptor col in this.gridGroupingControl1.TableDescriptor.Columns)
            {
                Regex  rex   = new Regex(@"\p{Lu}");
                int    index = rex.Match(col.MappingName.Substring(1)).Index;
                string name  = "";
                while (index > 0)
                {
                    name += col.MappingName.Substring(0, index + 1) + " ";
                    string secondName = col.MappingName.Substring(index + 1);
                    index = rex.Match(secondName.Substring(1)).Index;
                    while (index > 0)
                    {
                        name += secondName.Substring(0, index + 1) + " ";
                        index = rex.Match(col.MappingName.Substring(name.Replace(" ", "").Length).Substring(1)).Index;
                    }
                }
                name          += col.MappingName.Substring(name.Replace(" ", "").Length);
                col.HeaderText = name;
            }
            #endregion
        }
Beispiel #6
0
        /// <summary>
        /// Setting Grid control Properties
        /// </summary>
        private void GridSettings()
        {
            DataSet ds = new DataSet();

            ReadXml(ds, @"..\..\..\..\..\..\..\Common\Data\HVData.xml");
            int rowCount = gridControl1.RowCount = ds.Tables[1].Rows.Count;
            int colCount = gridControl1.ColCount = ds.Tables[1].Columns.Count;

            this.gridControl1.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, colCount), ds.Tables[1]);
            this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, rowCount - 1, colCount), ds.Tables[1]);
            this.gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Rows(1, rowCount - 1));
            this.gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Rows(0, colCount - 1));
            this.gridControl1.ColStyles[4].Format = "dd/MM/yyyy";
            this.gridControl1.ColStyles[5].Format = "dd/MM/yyyy";
            this.gridControl1.ColStyles[6].Format = "dd/MM/yyyy";
        }
Beispiel #7
0
        private List <ТаблицаОтчетнойФормы> ПолучитьТаблицыФормы(IWorksheet worksheet, ЭкраннаяФорма Форма)
        {
            ТаблицаОтчетнойФормы формы = new ТаблицаОтчетнойФормы();

            GridFormulaEngine.RegisterGridAsSheet("sys_общаяТаблица", формы.Представление, this.sheetFamilyID);
            base.ExcelToGrid(worksheet, формы.Представление);
            bool   flag   = false;
            int    top    = -1;
            string str    = string.Empty;
            int    length = worksheet.Rows.Length;
            int    right  = worksheet.Columns.Length;
            bool   flag2  = true;
            List <ТаблицаОтчетнойФормы> list = new List <ТаблицаОтчетнойФормы>();

            for (int i = 1; i <= length; i++)
            {
                string text = worksheet[i, 1].Text;
                if (string.IsNullOrEmpty(text))
                {
                    if ((i == length) && (top != -1))
                    {
                        text = "#Конец_Закладки";
                    }
                    else
                    {
                        continue;
                    }
                }
                if (text.ToLower().StartsWith("#закладка"))
                {
                    flag = false;
                    top  = i;
                    str  = text;
                }
                else if (text.ToLower().StartsWith("#динамическаятаблица"))
                {
                    flag = true;
                    top  = i;
                    str  = text;
                }
                else if (text.ToLower().StartsWith("#конец_закладки") && (top != -1))
                {
                    GridRangeInfo           range = GridRangeInfo.Cells(top, 1, i, right);
                    GridStyleInfoStoreTable cells = формы.GetCells(range);
                    int rowCount = cells.RowCount;
                    int colCount = cells.ColCount;
                    ТаблицаОтчетнойФормы формы2 = new ТаблицаОтчетнойФормы();
                    формы2.RowCount = rowCount;
                    формы2.ColCount = colCount;
                    this.ИдентифицироватьЗакладу(str, формы2);
                    string str3 = str.Trim().ToLower();
                    if (flag2)
                    {
                        формы2.ИмяЛиста = worksheet.Name;
                    }
                    else
                    {
                        формы2.ИмяЛиста = формы2.КодТаблицы;
                    }
                    flag2 = false;
                    GridFormulaEngine.RegisterGridAsSheet(формы2.ИмяЛиста, формы2.Представление, this.sheetFamilyID);
                    GridRangeInfo info2 = GridRangeInfo.Cells(1, 1, rowCount, colCount);
                    формы2.SetCells(info2, cells);
                    for (int j = 0; j <= colCount; j++)
                    {
                        формы2.ColWidths[j] = формы.ColWidths[j];
                    }
                    foreach (GridRangeInfo info3 in формы.CoveredRanges.Ranges)
                    {
                        формы2.CoveredRanges.Add(GridRangeInfo.Cells((info3.Top - top) + 1, info3.Left, (info3.Bottom - top) + 1, info3.Right));
                    }
                    формы2.RowHeights.ResizeToFit(GridRangeInfo.Rows(0, rowCount));
                    формы2.RowHeights[0]        = 0;
                    формы2.RowHeights[1]        = 0;
                    формы2.RowHeights[rowCount] = 0;
                    if (!flag)
                    {
                        this.ПроанализироватьТаблицуНаПеременные(формы2);
                        this.ОбработатьЯчейкиТаблицы(формы2);
                        Форма.ДобавитьТаблицу(формы2);
                    }
                    else
                    {
                        string[] strArray = формы2.КодТаблицы.Split(new char[] { ',' });
                        bool     flag3    = str3.Contains("размещатьназакладке");
                        foreach (string str4 in strArray)
                        {
                            ДинамическаяТаблица таблица = new ДинамическаяТаблица();
                            таблица.ПостроитьТаблицуПоМодели(формы2);
                            таблица.КодТаблицы         = str4;
                            таблица.азмещатьНаЗакладке = flag3;
                            Форма.ДобавитьДинамическуюТаблицу(таблица);
                        }
                    }
                    top = -1;
                }
            }
            GridFormulaEngine.UnregisterGridAsSheet("sys_общаяТаблица", формы.Представление);
            return(list);
        }
Beispiel #8
0
 private void radioButtonAdv11_CheckChanged(object sender, EventArgs e)
 {
     this.gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Rows(1, 5));
 }
Beispiel #9
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            #region Style settings
            GridModel model = gridControl1.Model;
            model.Options.FloatCellsMode = GridFloatCellsMode.OnDemandCalculation;

            GridFontInfo boldFont = new GridFontInfo();
            boldFont.Bold      = true;
            boldFont.Size      = 10;
            boldFont.Underline = true;

            int rowIndex = 2;
            int colIndex = 1;

            gridControl1.Rows.DefaultSize += 2;
            int boldfontRowHeight = gridControl1.Rows.DefaultSize + 6;

            model.Options.ControllerOptions         = GridControllerOptions.All;
            model.Options.DataObjectConsumerOptions = GridDataObjectConsumerOptions.All;

            GridStyleInfo standard  = model.BaseStylesMap["Standard"].StyleInfo;
            GridStyleInfo header    = model.BaseStylesMap["Header"].StyleInfo;
            GridStyleInfo rowHeader = model.BaseStylesMap["Row Header"].StyleInfo;
            GridStyleInfo colHeader = model.BaseStylesMap["Column Header"].StyleInfo;

            header.Interior    = new BrushInfo(SystemColors.Control);
            rowHeader.Interior = new BrushInfo(SystemColors.Control);

            standard.Font.Facename     = "Segoe UI";
            standard.VerticalAlignment = GridVerticalAlignment.Middle;

            #endregion

            #region Number Formats
            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text    = "Number Formats";
            model[rowIndex, 1].Font    = boldFont;
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            colIndex = 1;
            rowIndex++;
            foreach (string format in new string[]
            {
                "0.00",
                "C",
                "0.00;(0.00)",
                "###0.##%",
                "#0.#E+00",
                "10:##,##0.#"
            })
            {
                model[rowIndex - 1, colIndex].Text      = format;
                model[rowIndex, colIndex].Format        = format;
                model[rowIndex, colIndex].CellValue     = Math.PI;
                model[rowIndex, colIndex].CellValueType = typeof(double);
                colIndex++;
            }
            #endregion

            #region Date Formats

            rowIndex++;
            rowIndex++;

            colIndex = 1;

            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text    = "DateTime Formats";
            model[rowIndex, 1].Font    = boldFont;
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            colIndex = 1;
            rowIndex++;
            foreach (string format in new string[]
            {
                "d",
                "D",
                "f",
                "dddd, dd MMMM yyyy",
                "t",
                "s"
            })
            {
                model[rowIndex - 1, colIndex].Text      = format;
                model[rowIndex, colIndex].Format        = format;
                model[rowIndex, colIndex].CellValue     = DateTime.Now;
                model[rowIndex, colIndex].CellValueType = typeof(DateTime);
                colIndex++;
            }

            rowIndex++;
            rowIndex++;
            #endregion

            #region Validation
            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text    = "Validation";
            model[rowIndex, 1].Font    = boldFont;
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            model[rowIndex, 1].Text = "Positive numbers";
            model.RowStyles[rowIndex].ValidateValue.NumberRequired = true;
            model.RowStyles[rowIndex].ValidateValue.Minimum        = 0;
            model.RowStyles[rowIndex].ValidateValue.Maximum        = float.NaN;
            model.RowStyles[rowIndex].ValidateValue.ErrorMessage   = "Please enter a number greater than 0!";
            rowIndex++;

            model[rowIndex, 1].Text = "Validation (1-100 valid range)";
            model.RowStyles[rowIndex].ValidateValue = new GridCellValidateValueInfo(true, 1, 100, "Please enter a number between 1 and 100!");
            rowIndex++;
            rowIndex++;

            model[rowIndex, 1].Text = "Validation (allow strings to be entered into cells with CellValueType = typeof(double)";
            rowIndex++;
            model.RowStyles[rowIndex].CellValueType   = typeof(double);
            model.RowStyles[rowIndex].CellValue       = 1;
            model.RowStyles[rowIndex].Format          = "C";
            model.RowStyles[rowIndex].StrictValueType = false;
            rowIndex++;
            rowIndex++;

            model[rowIndex, 1].Text = "Validation (do not allow strings to be entered)";
            rowIndex++;
            model.RowStyles[rowIndex].CellValueType   = typeof(double);
            model.RowStyles[rowIndex].CellValue       = 1;
            model.RowStyles[rowIndex].Format          = "C";
            model.RowStyles[rowIndex].StrictValueType = true;
            rowIndex++;
            rowIndex++;

            model[rowIndex, 1].Text = "Validation (change CellValueType when strings is entered)";
            rowIndex++;
            model.RowStyles[rowIndex].CellValueType = typeof(double);
            model.RowStyles[rowIndex].CellValue     = 1;
            model.RowStyles[rowIndex].Format        = "C";
            model.RowStyles[rowIndex].Tag           = "Custom";
            rowIndex++;
            rowIndex++;
            #endregion

            #region TableStyle
            model.RowHeights.ResizeToFit(GridRangeInfo.Rows(2, rowIndex));
            this.gridControl1.DefaultRowHeight       = 18;
            this.gridControl1.DefaultColWidth        = 70;
            this.gridControl1.DefaultGridBorderStyle = GridBorderStyle.Solid;
            this.gridControl1.Font = new System.Drawing.Font("Segoe UI", 8.5F);
            #endregion

            this.GridSettings();
        }
Beispiel #10
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     this.grid.Model.ResizeRowsToFit(GridRangeInfo.Rows(3, 5), GridResizeToFitOptions.NoShrinkSize | GridResizeToFitOptions.IncludeCellsWithinCoveredRange);
 }