public static void SetupGridModel(GridModel model) { GridFactoryProvider.Init(new GridCellModelFactory()); model.Options.AlphaBlendSelectionColor = Color.FromArgb(64, SystemColors.Highlight); model.Options.AllowSelection = GridSelectionFlags.Any; //model.BaseStylesMap.RegisterStandardStyles(); model.CommandStack.Enabled = true; model.QueryCellModel += new GridQueryCellModelEventHandler(ModelQueryCellModel); model.OperationFeedbackListener = new DelayedStatusDialog(model); model.BeginInit(); model.RowCount = 1000; model.ColCount = 100; model.Rows.DefaultSize = 19; model.Cols.DefaultSize = 65; model.RowHeights[0] = 21; model.ColWidths[0] = 35; model.ColWidths[3] = 85; 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; model.Properties.GridLineColor = Color.FromArgb(65, 57, 73, 122); GridFontInfo boldFont = new GridFontInfo(); boldFont.Bold = true; boldFont.Size = 11; boldFont.Facename = "Helvetica"; standard.TextColor = Color.FromArgb(0, 21, 84); GridStyleInfo boldFontStyle = new GridStyleInfo(); boldFontStyle.TextColor = Color.FromArgb(238, 122, 3); boldFontStyle.Font = boldFont; header.Interior = new BrushInfo(GradientStyle.Vertical, Color.FromArgb(65, 238, 234, 216), Color.FromArgb(65, 203, 199, 184)); rowHeader.Interior = new BrushInfo(GradientStyle.Horizontal, Color.FromArgb(65, 238, 234, 216), Color.FromArgb(65, 203, 199, 184)); bool showImageList = false; if (showImageList) { ImageList imageList = new ImageList(); imageList.Images.Add(SystemIcons.Warning.ToBitmap()); imageList.Images.Add(SystemIcons.Application.ToBitmap()); imageList.Images.Add(SystemIcons.Asterisk.ToBitmap()); imageList.Images.Add(SystemIcons.Error.ToBitmap()); imageList.Images.Add(SystemIcons.Exclamation.ToBitmap()); imageList.Images.Add(SystemIcons.Hand.ToBitmap()); imageList.Images.Add(SystemIcons.Information.ToBitmap()); imageList.Images.Add(SystemIcons.Question.ToBitmap()); standard.ImageList = imageList; } ArrayList USStates = new ArrayList(); USStates.Add(new USState("Alabama", "AL", 0)); USStates.Add(new USState("Washington", "WA", 1)); USStates.Add(new USState("West Virginia", "WV", 2)); USStates.Add(new USState("Wisconsin", "WI", 3)); USStates.Add(new USState("Wyoming", "WY", 4)); USStates.Add(new USState("XAlabama", "AAL", 5)); USStates.Add(new USState("XWashington", "AWA", 6)); USStates.Add(new USState("XWest Virginia", "AWV", 1)); USStates.Add(new USState("XWisconsin", "AWI", 2)); USStates.Add(new USState("XWyoming", "AWY", 3)); USStates.Add(new USState("QAlabama", "BAL", 4)); USStates.Add(new USState("QWashington", "BWA", 5)); USStates.Add(new USState("QWest Virginia", "BWV", 6)); USStates.Add(new USState("QWisconsin", "BWI", 0)); USStates.Add(new USState("QWyoming", "BWY", 1)); standard.DataSource = USStates; standard.DisplayMember = "LongName"; standard.ValueMember = "ShortName"; Type type = typeof(Bitmap); System.IO.Stream stream = typeof(SampleGrid).Module.Assembly.GetManifestResourceStream(ApplicationMain.manifestNamespace + "logo_105_65.bmp"); Bitmap bm = new Bitmap(stream); ImageList logoList = new ImageList(); logoList.Images.Add(bm); logoList.ImageSize = bm.Size; logoList.ColorDepth = ColorDepth.Depth32Bit; int rowIndex = 2; int colIndex = 1; int boldfontRowHeight = 0; model.Options.FloatCellsMode = GridFloatCellsMode.OnDemandCalculation; model.CoveredRanges.Add(GridRangeInfo.Cells(2, 2, 4, 4)); model[2, 2].Text = "Grid Demo"; model[2, 2].Font.Bold = true; model[2, 2].Font.Size = 16; model[2, 2].HorizontalAlignment = GridHorizontalAlignment.Center; model[2, 2].VerticalAlignment = GridVerticalAlignment.Middle; model[2, 2].CellType = "Static"; model[2, 2].Borders.All = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(65, 238, 122, 3)); model[2, 2].Interior = new BrushInfo(GradientStyle.PathEllipse, Color.FromArgb(65, 57, 73, 122), Color.FromArgb(65, 237, 240, 247)); rowIndex += 5; model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); model[rowIndex, 1].Text = "Interior"; model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle); model.RowHeights.ResizeToFit(GridRangeInfo.Cell(rowIndex, 1), GridResizeToFitOptions.ResizeCoveredCells | GridResizeToFitOptions.NoShrinkSize); boldfontRowHeight = model.RowHeights[rowIndex]; rowIndex++; colIndex = 1; foreach (int index in new int[] { 1, 2, 3, 4, 5, 6, }) { model[rowIndex, colIndex].ImageIndex = index; colIndex++; } rowIndex++; colIndex = 1; foreach (Color color1 in new Color[] { Color.FromArgb(65, 0, 0, 51), Color.FromArgb(65, 252, 172, 38), Color.FromArgb(65, 33, 67, 126), Color.FromArgb(65, 102, 110, 152), Color.FromArgb(65, 204, 212, 230), Color.FromArgb(65, 237, 240, 247), }) { model[rowIndex, colIndex].Interior = new BrushInfo(color1); colIndex++; } rowIndex++; colIndex = 1; foreach (PatternStyle pattern in new PatternStyle[] { PatternStyle.Percent05, PatternStyle.Percent20, PatternStyle.Percent50, PatternStyle.Percent75, PatternStyle.DarkDownwardDiagonal, PatternStyle.LightDownwardDiagonal }) { model[rowIndex, colIndex].Interior = new BrushInfo(pattern, Color.FromArgb(65, 237, 240, 247), Color.FromArgb(65, 57, 73, 122)); colIndex++; } rowIndex++; colIndex = 1; foreach (GradientStyle gradient in new GradientStyle[] { GradientStyle.BackwardDiagonal, GradientStyle.ForwardDiagonal, GradientStyle.PathEllipse, GradientStyle.PathRectangle, GradientStyle.Vertical, GradientStyle.Horizontal, }) { model[rowIndex, colIndex].Interior = new BrushInfo(gradient, Color.FromArgb(65, 57, 73, 122), Color.FromArgb(65, 237, 240, 247)); model[rowIndex + 1, colIndex].Interior = new BrushInfo(gradient, Color.FromArgb(65, 237, 240, 247), Color.FromArgb(65, 51, 51, 102)); colIndex++; } rowIndex++; rowIndex++; rowIndex++; colIndex = 1; model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); model[rowIndex, 1].Text = "Font"; model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle); model.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; foreach (int size in new int[] { 6, 7, 8, 10, 12, 14 }) { model[rowIndex, colIndex].Font.Size = size; model[rowIndex, colIndex].Text = size.ToString(); colIndex++; } model.RowHeights.ResizeToFit(GridRangeInfo.Row(rowIndex), GridResizeToFitOptions.ResizeCoveredCells | GridResizeToFitOptions.NoShrinkSize); rowIndex++; colIndex = 1; foreach (FontStyle fontStyle in new FontStyle[] { FontStyle.Bold, FontStyle.Italic, FontStyle.Regular, FontStyle.Strikeout, FontStyle.Underline, FontStyle.Bold | FontStyle.Italic | FontStyle.Regular, }) { model[rowIndex, colIndex].Font.FontStyle = fontStyle; model[rowIndex, colIndex].Text = Enum.Format(typeof(FontStyle), fontStyle, "G"); colIndex++; } rowIndex++; rowIndex++; colIndex = 1; model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); model[rowIndex, 1].Text = "TextColor"; model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle); model.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; colIndex = 1; foreach (Color color2 in new Color[] { Color.Black, Color.Red, Color.Blue, Color.Green, Color.Yellow, Color.DimGray }) { model[rowIndex, colIndex].TextColor = color2; model[rowIndex, colIndex].Text = ColorConvert.ColorToString(color2, true); colIndex++; } rowIndex++; rowIndex++; colIndex = 1; model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); model[rowIndex, 1].Text = "Number Formats"; model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle); model.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; colIndex = 1; foreach (string format2 in new string[] { "0.00", "C", "0.00;(0.00)", "###0.##%", "#0.#E+00", "10:##,##0.#" }) { model[rowIndex, colIndex].Format = format2; model[rowIndex, colIndex].CellValue = Math.PI; model[rowIndex, colIndex].CellValueType = typeof(double); colIndex++; } rowIndex++; rowIndex++; colIndex = 1; model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); model[rowIndex, 1].Text = "DateTime Formats"; model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle); model.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; colIndex = 1; foreach (string format in new string[] { "d", "D", "f", "dddd, dd MMMM yyyy", "t", "s" }) { model[rowIndex, colIndex].Format = format; model[rowIndex, colIndex].CellValue = DateTime.Now; model[rowIndex, colIndex].CellValueType = typeof(DateTime); colIndex++; } rowIndex++; rowIndex++; model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); model[rowIndex, 1].Text = "Validation"; model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle); 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.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); model[rowIndex, 1].Text = "Cell Types"; model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle); model.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; colIndex = 1; model.TableStyle.CheckBoxOptions = new GridCheckBoxCellInfo("True", "False", "", false); model[rowIndex, 1].Text = "CheckBox"; model[rowIndex, 3].CellType = "CheckBox"; model[rowIndex, 3].TriState = false; model[rowIndex, 3].Text = "True"; model[rowIndex, 3].VerticalAlignment = GridVerticalAlignment.Middle; model[rowIndex, 3].Description = "Enabled"; model[rowIndex, 4].CellType = "CheckBox"; model[rowIndex, 4].Text = "False"; model[rowIndex, 4].Enabled = false; model[rowIndex, 4].Description = "Disabled"; model[rowIndex, 4].VerticalAlignment = GridVerticalAlignment.Middle; model[rowIndex, 5].CellType = "CheckBox"; model[rowIndex, 5].TriState = true; model[rowIndex, 5].Description = "TriState"; model[rowIndex, 5].VerticalAlignment = GridVerticalAlignment.Middle; rowIndex++; rowIndex++; rowIndex++; model[rowIndex, 1].Text = "DragButton"; model[rowIndex, 3].Text = "Drag"; model[rowIndex, 3].CellType = "DragButton"; rowIndex++; model.TableStyle.NumericUpDown = new GridNumericUpDownCellInfo(0, 25, 1, 1, true); model[rowIndex, 1].Text = "NumericUpDown"; // Wrapping, Range 0-1000 model[rowIndex, 3].CellType = "NumericUpDown"; model[rowIndex, 3].NumericUpDown = new GridNumericUpDownCellInfo(0, 1000, 0, 1, true); // Disabled model[rowIndex, 4].CellType = "NumericUpDown"; model[rowIndex, 4].Enabled = false; model[rowIndex, 4].Text = "5"; // No wrapping, Range 1-20 model[rowIndex, 5].CellType = "NumericUpDown"; model[rowIndex, 5].NumericUpDown = new GridNumericUpDownCellInfo(1, 20, 1, 1, false); rowIndex++; model[rowIndex, 1].Text = "PushButton"; model[rowIndex, 3].CellType = "PushButton"; model[rowIndex, 3].Description = "Enabled"; model[rowIndex, 4].CellType = "PushButton"; model[rowIndex, 4].Enabled = false; model[rowIndex, 4].Clickable = false; model[rowIndex, 4].Description = "Disabled"; rowIndex++; StringCollection items = new StringCollection(); items.Add("One"); items.Add("Two"); items.Add("Three"); items.Add("Four"); items.Add("Five"); items.Add("Six"); items.Add("Seven"); items.Add("Eight"); items.Add("Nine"); items.Add("Ten"); model[rowIndex, 1].Text = "ComboBox (Edit)"; model[rowIndex, 3].CellType = "ComboBox"; model[rowIndex, 3].ChoiceList = items; // Disabled model[rowIndex, 4].CellType = "ComboBox"; model[rowIndex, 4].ChoiceList = items; model[rowIndex, 4].Enabled = false; model[rowIndex, 4].CellValue = items[5]; rowIndex++; model[rowIndex, 1].Text = "ComboBox (List)"; model[rowIndex, 3].CellType = "ComboBox"; model[rowIndex, 3].ChoiceList = items; model[rowIndex, 3].ExclusiveChoiceList = true; // tell combobox to behave like CBS_DROPDOWNSTYLE // Disabled model[rowIndex, 4].CellType = "ComboBox"; model[rowIndex, 4].ChoiceList = items; model[rowIndex, 4].Enabled = false; model[rowIndex, 4].ExclusiveChoiceList = true; // tell combobox to behave like CBS_DROPDOWNSTYLE model[rowIndex, 4].CellValue = items[5]; rowIndex++; rowIndex++; model[rowIndex, 1].Text = "GridListControl (Edit)"; model[rowIndex, 3].CellType = "GridListControl"; model[rowIndex, 3].DataSource = USStates; // Disabled model[rowIndex, 4].CellType = "GridListControl"; model[rowIndex, 4].DataSource = USStates; rowIndex++; model[rowIndex, 1].Text = "GridListControl (List)"; model[rowIndex, 3].CellType = "GridListControl"; model[rowIndex, 3].DataSource = USStates; model[rowIndex, 3].ExclusiveChoiceList = true; // tell combobox to behave like CBS_DROPDOWNSTYLE rowIndex++; rowIndex++; model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); model[rowIndex, 1].Text = "DropDown Cells"; model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle); model.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; // model[rowIndex, 1].Text = "Generic DropDown"; model[rowIndex, 3].CellType = "DropDown"; rowIndex++; model[rowIndex, 1].Text = "MonthCalendar"; model[rowIndex, 3].CellType = "MonthCalendar"; rowIndex++; model[rowIndex, 1].Text = "ColorEdit"; model[rowIndex, 3].CellType = "ColorEdit"; rowIndex++; model[rowIndex, 1].Text = "DropDownGrid"; model[rowIndex, 3].CellType = "DropDownGrid"; rowIndex++; rowIndex++; colIndex = 1; model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); model[rowIndex, 1].Text = "Borders"; model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle); model.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; foreach (GridBorder border2 in new GridBorder[] { new GridBorder(GridBorderStyle.Solid, Color.FromArgb(57, 73, 122)), new GridBorder(GridBorderStyle.Dotted, Color.FromArgb(238, 122, 3)), new GridBorder(GridBorderStyle.DashDot, Color.FromArgb(57, 73, 122)), new GridBorder(GridBorderStyle.DashDotDot, Color.FromArgb(238, 122, 3)), new GridBorder(GridBorderStyle.Dashed, Color.FromArgb(57, 73, 122), GridBorderWeight.Medium), new GridBorder(GridBorderStyle.Dotted, Color.FromArgb(238, 122, 3), GridBorderWeight.Medium), }) { model[rowIndex, colIndex].Borders.Bottom = border2; model[rowIndex, colIndex].Borders.Right = border2; model[rowIndex, colIndex].Text = border2.ToString(); colIndex++; } rowIndex++; colIndex = 1; foreach (GridBorder border in new GridBorder[] { new GridBorder(GridBorderStyle.Dashed, Color.FromArgb(57, 73, 122), GridBorderWeight.Thick), new GridBorder(GridBorderStyle.Dotted, Color.FromArgb(238, 122, 3), GridBorderWeight.Thick), new GridBorder(GridBorderStyle.DashDot, Color.FromArgb(57, 73, 122), GridBorderWeight.Medium), new GridBorder(GridBorderStyle.DashDotDot, Color.FromArgb(238, 122, 3), GridBorderWeight.Medium), new GridBorder(GridBorderStyle.Solid, Color.FromArgb(57, 73, 122), GridBorderWeight.Thick), new GridBorder(GridBorderStyle.Solid, Color.FromArgb(238, 122, 3), GridBorderWeight.Medium), }) { model[rowIndex, colIndex].Borders.Bottom = border; model[rowIndex, colIndex].Borders.Right = border; model[rowIndex, colIndex].Text = border.ToString(); colIndex++; } rowIndex++; rowIndex++; colIndex = 1; model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); model[rowIndex, 1].Text = "Orientation"; model[rowIndex, 1].ModifyStyle(boldFontStyle, StyleModifyType.Override); model.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; foreach (int orientation in new int[] { 0, 45, 60, 90, 180, -90 }) { GridStyleInfo style1 = model[rowIndex, colIndex]; // style1 is a direct reference to model[rowIndex, colIndex]; // changes will be propagated back to GridData style1.HorizontalAlignment = GridHorizontalAlignment.Center; style1.VerticalAlignment = GridVerticalAlignment.Middle; GridFontInfo font = style1.Font; font.Orientation = orientation; font.Bold = true; style1.Text = "Angle = " + font.Orientation.ToString(); colIndex++; } rowIndex++; rowIndex++; colIndex = 1; model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); model[rowIndex, 1].Text = "Enabled"; model[rowIndex, 1].ModifyStyle(boldFontStyle, StyleModifyType.Override); model.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; foreach (bool enabled1 in new bool[] { true, false, true, false, false, true, }) { model[rowIndex, colIndex].Text = enabled1?"YES":"NO"; model[rowIndex, colIndex].Interior = new BrushInfo((Color)(enabled1?Color.FromArgb(65, 57, 73, 122):Color.FromArgb(65, 238, 122, 3))); model[rowIndex, colIndex].Enabled = enabled1; colIndex++; } colIndex = 1; rowIndex++; foreach (bool enabled2 in new bool[] { true, true, false, false, false, true, }) { model[rowIndex, colIndex].Text = enabled2?"YES":"NO"; model[rowIndex, colIndex].Interior = new BrushInfo((Color)(enabled2?Color.FromArgb(65, 57, 73, 122):Color.FromArgb(65, 238, 122, 3))); model[rowIndex, colIndex].Enabled = enabled2; colIndex++; } rowIndex++; rowIndex++; colIndex = 1; model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); model[rowIndex, 1].Text = "AutoSize"; model[rowIndex, 1].ModifyStyle(boldFontStyle, StyleModifyType.Override); model.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; model.RowStyles[rowIndex].AutoSize = true; model.RowStyles[rowIndex].Text = "Row height will increase while you type text"; model.RowStyles[rowIndex].Interior = new BrushInfo(Color.Beige); rowIndex++; rowIndex++; colIndex = 1; model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); model[rowIndex, 1].Text = "Read Only"; model[rowIndex, 1].ModifyStyle(boldFontStyle, StyleModifyType.Override); model.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; model.RowStyles[rowIndex].ReadOnly = true; model.RowStyles[rowIndex].Interior = new BrushInfo(Color.LightGray); model.RowStyles[rowIndex].Text = "ReadOnly"; rowIndex++; rowIndex++; model.Options.ExcelLikeCurrentCell = false; model.Options.ExcelLikeSelectionFrame = false; model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.ClickOnCell; model.Properties.MarkColHeader = true; model.Properties.MarkRowHeader = true; model.RowHeights.ResizeToFit(GridRangeInfo.Cells(2, 1, rowIndex, 3), GridResizeToFitOptions.ResizeCoveredCells | GridResizeToFitOptions.NoShrinkSize); model.EndInit(); }
private void InitializeGrid() { this.gridControl1.BeginUpdate(); #region Cell Styles gridControl1.TableStyle.FloatCell = true; gridControl1.FloatCellsMode = GridFloatCellsMode.BeforeDisplayCalculation; gridControl1.ColWidths[3] = (int)DpiAware.LogicalToDeviceUnits(90); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(1, 1, 2, gridControl1.ColCount)); gridControl1[1, 1].CellValue = "DropDown Cells"; gridControl1[1, 1].Font.Size = 14; gridControl1[1, 1].Font.Bold = true; gridControl1[1, 1].VerticalAlignment = GridVerticalAlignment.Middle; gridControl1[1, 1].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1[1, 1].CellType = "Static"; this.gridControl1.CheckBoxClick += new GridCellClickEventHandler(gridControl1_CheckBoxClick); #endregion #region DataSources // // Creating DataSource // StringCollection items = new StringCollection(); items.Add("One"); items.Add("Two"); items.Add("Three"); items.Add("Four"); items.Add("Five"); items.Add("Six"); items.Add("Seven"); items.Add("Eight"); items.Add("Nine"); items.Add("Ten"); ImageList imageList = new ImageList(); imageList.Images.Add(SystemIcons.Warning.ToBitmap()); imageList.Images.Add(SystemIcons.Application.ToBitmap()); imageList.Images.Add(SystemIcons.Asterisk.ToBitmap()); imageList.Images.Add(SystemIcons.Error.ToBitmap()); imageList.Images.Add(SystemIcons.Information.ToBitmap()); imageList.Images.Add(SystemIcons.Question.ToBitmap()); this.gridControl1.TableStyle.ImageList = imageList; ArrayList icons = new ArrayList(); icons.Add(new IconDesc("Warning", "WA", 0)); icons.Add(new IconDesc("Application", "AP", 1)); icons.Add(new IconDesc("Asterisk", "AS", 2)); icons.Add(new IconDesc("Error", "ER", 3)); icons.Add(new IconDesc("Information", "INF", 4)); icons.Add(new IconDesc("Question", "QUE", 5)); #endregion #region ComboBox Cells this.gridControl1.Model.EnableGridListControlInComboBox = false; int rowIndex = 4; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1].CellType = GridCellTypeName.CheckBox; gridControl1[rowIndex, 1].Description = "ComboBox with AutoComplete in Editmode"; gridControl1[rowIndex, 1].Font.Bold = true; AddChoices(ref rowIndex, "ComboBox", items, null, "", ""); for (int i = 5; i <= 8; i++) { this.gridControl1.HideRows[i] = true; } // ComboBox using ChoiceList rowIndex = 10; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex - 1, 1, rowIndex - 1, gridControl1.ColCount)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1].CellType = GridCellTypeName.CheckBox; gridControl1[rowIndex, 1].Description = "ComboBox using ChoiceList"; gridControl1[rowIndex, 1].Font.Bold = true; gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Row(rowIndex), GridResizeToFitOptions.ResizeCoveredCells); AddEntries(ref rowIndex, "ComboBox", items, null, "", ""); for (int i = 11; i <= 19; i++) { this.gridControl1.HideRows[i] = true; } //ComboBox using Datasource"; rowIndex = 21; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex - 1, 1, rowIndex - 1, gridControl1.ColCount)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1].CellType = GridCellTypeName.CheckBox; gridControl1[rowIndex, 1].Description = "ComboBox using Datasource, DisplayMember = CompanyName"; gridControl1[rowIndex, 1].Font.Bold = true; gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Row(rowIndex), GridResizeToFitOptions.ResizeCoveredCells); AddEntries(ref rowIndex, "ComboBox", null, dataSet11.Customers, "CustomerID", "CompanyName"); for (int i = 22; i <= 30; i++) { this.gridControl1.HideRows[i] = true; } rowIndex = 32; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex - 1, 1, rowIndex - 1, gridControl1.ColCount)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1].CellType = GridCellTypeName.CheckBox; gridControl1[rowIndex, 1].Description = "ComboBox using Datasource, ValueMember = empty "; gridControl1[rowIndex, 1].Font.Bold = true; gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Row(rowIndex), GridResizeToFitOptions.ResizeCoveredCells); AddEntries(ref rowIndex, "ComboBox", null, dataSet11.Customers, "", "CompanyName"); for (int i = 33; i <= 41; i++) { this.gridControl1.HideRows[i] = true; } rowIndex = 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1].CellType = GridCellTypeName.Static; gridControl1[rowIndex, 1].Text = "ComboBox Cells : Following Categories illustrates the features supported by a ComboBox cell"; gridControl1[rowIndex, 1].TextColor = Color.Black; gridControl1[rowIndex, 1].Font.Bold = true; #endregion #region GridListControl Cells rowIndex = 46; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex - 1, 1, rowIndex - 1, gridControl1.ColCount)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1].CellType = GridCellTypeName.CheckBox; gridControl1[rowIndex, 1].Description = "GridListControl using Datasource, DisplayMember = CompanyName"; gridControl1[rowIndex, 1].Font.Bold = true; gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Row(rowIndex), GridResizeToFitOptions.ResizeCoveredCells); AddEntries(ref rowIndex, "GridListControl", null, dataSet11.Customers, "CustomerID", "CompanyName"); for (int i = 47; i <= 55; i++) { this.gridControl1.HideRows[i] = true; } rowIndex = 57; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex - 1, 1, rowIndex - 1, gridControl1.ColCount)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1].CellType = GridCellTypeName.CheckBox; gridControl1[rowIndex, 1].Description = "GridListControl using Datasource, ValueMember = empty"; gridControl1[rowIndex, 1].Font.Bold = true; gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Row(rowIndex), GridResizeToFitOptions.ResizeCoveredCells); AddEntries(ref rowIndex, "GridListControl", null, dataSet11.Customers, "", "CompanyName"); for (int i = 58; i <= 66; i++) { this.gridControl1.HideRows[i] = true; } rowIndex = 68; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex - 1, 1, rowIndex - 1, gridControl1.ColCount)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1].CellType = GridCellTypeName.CheckBox; gridControl1[rowIndex, 1].Description = "GridListControl showing ArrayList with Icons"; gridControl1[rowIndex, 1].Font.Bold = true; gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Row(rowIndex), GridResizeToFitOptions.ResizeCoveredCells); AddEntries(ref rowIndex, "GridListControl", null, icons, "", "LongName"); for (int i = 69; i <= 77; i++) { this.gridControl1.HideRows[i] = true; } rowIndex = 43; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex - 1, 1, rowIndex - 1, gridControl1.ColCount)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1].CellType = GridCellTypeName.Static; gridControl1[rowIndex, 1].Text = "GridListControl Cells : Following Categories illustrates the features supported by a GridListControl cell"; gridControl1[rowIndex, 1].TextColor = Color.Black; gridControl1[rowIndex, 1].Font.Bold = true; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1].Text = "GridListControl using ChoiceList : Not Supported"; gridControl1[rowIndex, 1].Font.Bold = true; #endregion #region MonthCalendar Cells rowIndex = 79; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex - 1, 1, rowIndex - 1, gridControl1.ColCount)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 4)); gridControl1[rowIndex, 1].Text = "DropDown Calendar Cells"; gridControl1[rowIndex, 1].TextColor = Color.Black; gridControl1[rowIndex, 1].Font.Bold = true; rowIndex++; gridControl1[rowIndex, 1].CellType = "MonthCalendar"; gridControl1[rowIndex, 1].CellValue = DateTime.Now; gridControl1[rowIndex, 1].Font.Size = 8; gridControl1[rowIndex, 3].CellType = "MonthCalendar"; gridControl1[rowIndex, 3].CellValue = DateTime.Now; gridControl1[rowIndex, 3].Font.Size = 8; gridControl1.RowHeights[rowIndex] = gridControl1.DefaultRowHeight - 2; #endregion #region Coloredit Cells rowIndex = 79; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 5, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 5].Text = "DropDown ColorEdit Cells"; gridControl1[rowIndex, 5].TextColor = Color.Black; gridControl1[rowIndex, 5].Font.Bold = true; rowIndex++; gridControl1[rowIndex, 5].CellType = GridCellTypeName.ColorEdit; gridControl1[rowIndex, 5].TextColor = Color.Black; gridControl1[rowIndex, 5].Font.Size = 8; gridControl1[rowIndex, 7].CellType = GridCellTypeName.ColorEdit; gridControl1[rowIndex, 7].TextColor = Color.Black; gridControl1[rowIndex, 7].Font.Size = 8; gridControl1.RowHeights[rowIndex] = gridControl1.DefaultRowHeight - 2; #endregion #region RichTextCells rowIndex = 82; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex - 1, 1, rowIndex - 1, gridControl1.ColCount)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1].CellType = GridCellTypeName.CheckBox; gridControl1[rowIndex, 1].Description = "Rich Text Cells : Check this to view a drop-down menu which displays formatting helpers to modify the text"; gridControl1[rowIndex, 1].TextColor = Color.Black; gridControl1[rowIndex, 1].Font.Bold = true; rowIndex = 83; rtf2 = @"{\rtf1\ansi" + // font table @"{\fonttbl" + @"\f0\froman Times New Roman; " + @"\f1\fdecor Courier New; " + @"\f2\fswiss Arial;} " + @"\deff0 " + // color table @"{\colortbl" + @"\red250\green177\blue146; " + @"\red229\green 118\blue145; " + @"\red101\green121\blue219; " + @"\red240\green224\blue255;} " + // first line @"\highlight2\cb1\qc\cf0\f0\fs20 12 point, Times New Roman, " + @"red, centered\plain\par" + // second line @"\highlight0\ql\cf3\f1\fs28 14 point, Courier New, blue, " + @"left aligned\plain\par" + // third line @"\highlight1\qr\cf0\f2\fs36 18 point, Arial, black, " + @"right aligned\plain\par" + // fourth line @"\qc Default font and color, \b Bold\plain , \ul Underline\plain , \i Italic \plain\par" + // closing bracket @"}" ; gridControl1[rowIndex, 1].CellType = "RichText"; gridControl1[rowIndex, 1].Text = rtf2; gridControl1.RowHeights[rowIndex] = 150; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 5)); this.gridControl1.HideRows[rowIndex] = true; #endregion this.gridControl1.EndUpdate(true); }
/// <summary> /// Setting Grid control Properties /// </summary> private void GridSettings() { this.gridControl1.ControllerOptions = GridControllerOptions.All & (~GridControllerOptions.OleDataSource); gridControl1.CommandStack.Enabled = false; this.excelMarker = new ExcelMarkerMouseController(gridControl1); gridControl1.MouseControllerDispatcher.Add(excelMarker); this.SuspendLayout(); GridBorder thickBorder = new GridBorder(GridBorderStyle.Solid, Color.Gray, GridBorderWeight.Medium); int rowIndex = rowBase + 1; int colIndex = colBase + 1; gridControl1.TableStyle.CheckBoxOptions = new GridCheckBoxCellInfo("True", "False", "", false); gridControl1[rowIndex, colIndex].CellType = "CheckBox"; gridControl1[rowIndex, colIndex].TriState = false; gridControl1[rowIndex, colIndex].Text = "True"; gridControl1[rowIndex, colIndex].VerticalAlignment = GridVerticalAlignment.Middle; gridControl1[rowIndex, colIndex].Description = " ExcelLikeCurrentCell"; rowIndex++; gridControl1[rowIndex, colIndex].CellType = "CheckBox"; gridControl1[rowIndex, colIndex].TriState = false; gridControl1[rowIndex, colIndex].Text = "True"; gridControl1[rowIndex, colIndex].VerticalAlignment = GridVerticalAlignment.Middle; gridControl1[rowIndex, colIndex].Description = " ExcelLikeSelectionFrame"; rowIndex++; gridControl1[rowIndex, colIndex].CellType = "CheckBox"; gridControl1[rowIndex, colIndex].TriState = false; gridControl1[rowIndex, colIndex].Text = "True"; gridControl1[rowIndex, colIndex].VerticalAlignment = GridVerticalAlignment.Middle; gridControl1[rowIndex, colIndex].Description = " ExcelMarker"; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].Borders.Top = thickBorder; gridControl1[rowIndex, colIndex].Borders.Left = thickBorder; gridControl1[rowIndex, colIndex].Borders.Right = thickBorder; gridControl1[rowIndex, colIndex].Text = "Selection Color"; gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1[rowIndex, colIndex].VerticalAlignment = GridVerticalAlignment.Bottom; gridControl1[rowIndex, colIndex].Font.Size = 8; gridControl1[rowIndex, colIndex].TextColor = Color.Gray; gridControl1[rowIndex, colIndex].Enabled = false; rowIndex++; gridControl1[rowIndex, colIndex].Borders.Left = thickBorder; gridControl1[rowIndex, colIndex].Borders.Right = thickBorder; gridControl1[rowIndex, colIndex].CellValue = Color.FromName("Highlight");//Color.FromArgb( 255, 187, 111 ); gridControl1[rowIndex, colIndex].CellType = "ColorEdit"; gridControl1[rowIndex, colIndex].TextColor = Color.White; gridControl1[rowIndex, colIndex].CellValueType = typeof(Color); gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1[rowIndex, colIndex].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(163)))), ((int)(((byte)(0))))); gridControl1[rowIndex, colIndex].Font.Size = 8; rowIndex++; gridControl1[rowIndex, colIndex].Borders.Left = thickBorder; gridControl1[rowIndex, colIndex].Borders.Right = thickBorder; rowIndex++; gridControl1[rowIndex, colIndex].Borders.Left = thickBorder; gridControl1[rowIndex, colIndex].Borders.Right = thickBorder; gridControl1[rowIndex, colIndex].Text = "Alpha Blend Value (0-255)"; gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1[rowIndex, colIndex].VerticalAlignment = GridVerticalAlignment.Bottom; gridControl1[rowIndex, colIndex].Font.Size = 8; gridControl1[rowIndex, colIndex].TextColor = Color.Gray; gridControl1[rowIndex, colIndex].Enabled = false; rowIndex++; gridControl1[rowIndex, colIndex].Borders.Left = thickBorder; gridControl1[rowIndex, colIndex].Borders.Right = thickBorder; gridControl1[rowIndex, colIndex].CellType = "NumericUpDown"; gridControl1[rowIndex, colIndex].CellValue = alphaBlendValue; gridControl1[rowIndex, colIndex].CellValueType = typeof(int); gridControl1[rowIndex, colIndex].NumericUpDown = new GridNumericUpDownCellInfo(0, 255, 0, 1, true); gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1[rowIndex, colIndex].Font.Size = 8; rowIndex++; gridControl1[rowIndex, colIndex].Borders.Left = thickBorder; gridControl1[rowIndex, colIndex].Borders.Right = thickBorder; rowIndex++; gridControl1[rowIndex, colIndex].Borders.Bottom = thickBorder; gridControl1[rowIndex, colIndex].Borders.Left = thickBorder; gridControl1[rowIndex, colIndex].Borders.Right = thickBorder; gridControl1[rowIndex, colIndex].CellType = "PushButton"; gridControl1[rowIndex, colIndex].Description = "Apply"; gridControl1[rowIndex, colIndex].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(163)))), ((int)(((byte)(0))))); gridControl1.Model.RowHeights[rowIndex] = 25; gridControl1.Rows.DefaultSize += 1; gridControl1.DefaultColWidth = 70; gridControl1.ColWidths.SetSize(colIndex, 230); //add a custom cell control that draws a mitmap gridControl1.CellModels.Add("ImageCell", new ImageCellModel(gridControl1.Model)); //read a bitmap from resources //strm = this.GetType().Assembly.GetManifestResourceStream("ExcelMarker.grid.gif"); Bitmap bm = GetImage(@"Common\Images\Grid\SelectionMarker\grid.gif");// new Bitmap(strm); //set up covered cell to show the bitmap gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(1, 2, 5, 9)); gridControl1[1, 2].Tag = bm; //Tag used to hold the bitmap gridControl1[1, 2].CellType = "ImageCell"; //set some grid properties gridControl1.FloatCellsMode = GridFloatCellsMode.BeforeDisplayCalculation; gridControl1.AlphaBlendSelectionColor = Color.FromArgb(alphaBlendValue, Color.FromName("Highlight")); gridControl1.BorderStyle = BorderStyle.None; this.gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(7, 3, 10, 6)); this.gridControl1[7, 3].Borders.All = new GridBorder(GridBorderStyle.Solid, Color.Orange, GridBorderWeight.Thick); this.gridControl1[7, 3].Text = "Make some selections and then change the Excel-Like properties and selection color properties listed to the left."; this.gridControl1[7, 3].Font.Size = 9; this.gridControl1[7, 3].Font.Bold = false; this.gridControl1[7, 3].Font.Facename = "Helvetica"; this.gridControl1[7, 3].TextColor = Color.Orange; this.gridControl1[7, 3].Enabled = false; this.gridControl1[7, 3].VerticalAlignment = GridVerticalAlignment.Middle; this.gridControl1[7, 3].HorizontalAlignment = GridHorizontalAlignment.Left; //set default row height this.gridControl1.DefaultRowHeight = 22; }
public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); #region Custom Cells gridControl1.DefaultRowHeight = 22; gridControl1.ExcelLikeCurrentCell = true; gridControl1.ExcelLikeSelectionFrame = true; gridControl1.ControllerOptions = GridControllerOptions.All; gridControl1.HScrollBehavior = GridScrollbarMode.Disabled; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(1, 1, 2, gridControl1.ColCount)); gridControl1[1, 1].Text = "Derived Cell Controls"; gridControl1[1, 1].Font.Bold = true; gridControl1[1, 1].Font.Size = 12; gridControl1[1, 1].TextColor = Color.Black; gridControl1[1, 1].CellType = GridCellTypeName.Static; gridControl1[1, 1].VerticalAlignment = GridVerticalAlignment.Middle; gridControl1[1, 1].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.CellModels.Add("LinkLabelCell", new LinkLabelCellModel(gridControl1.Model)); int rowIndex = 4; gridControl1[rowIndex, 4].Text = "Syncfusion, Inc."; gridControl1[rowIndex, 4].Font.Bold = true; gridControl1[rowIndex, 4].Tag = "http://www.syncfusion.com"; gridControl1[rowIndex, 4].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1[rowIndex, 4].CellType = "LinkLabelCell"; rowIndex++; gridControl1[rowIndex, 4].CellType = "LinkLabelCell"; gridControl1[rowIndex, 4].Text = "Windows Forms FAQ"; gridControl1[rowIndex, 4].Font.Bold = true; gridControl1[rowIndex, 4].Tag = "http://www.syncfusion.com/support/forums/grid-windows"; gridControl1[rowIndex, 4].HorizontalAlignment = GridHorizontalAlignment.Center; rowIndex++; gridControl1[rowIndex, 4].CellType = "LinkLabelCell"; gridControl1[rowIndex, 4].Text = "Microsoft Windows Forms"; gridControl1[rowIndex, 4].Font.Bold = true; gridControl1[rowIndex, 4].Tag = "http://windowsforms.net/"; gridControl1[rowIndex, 4].HorizontalAlignment = GridHorizontalAlignment.Center; rowIndex++; gridControl1[rowIndex, 4].CellType = "LinkLabelCell"; gridControl1[rowIndex, 4].Text = "MSDN"; gridControl1[rowIndex, 4].Font.Bold = true; gridControl1[rowIndex, 4].Tag = "http://msdn.microsoft.com"; gridControl1[rowIndex, 4].HorizontalAlignment = GridHorizontalAlignment.Center; rowIndex++; gridControl1[rowIndex, 4].CellType = "LinkLabelCell"; gridControl1[rowIndex, 4].Text = "Yahoo"; gridControl1[rowIndex, 4].Font.Bold = true; gridControl1[rowIndex, 4].Tag = "http://www.yahoo.com"; gridControl1[rowIndex, 4].HorizontalAlignment = GridHorizontalAlignment.Center; rowIndex++; gridControl1[rowIndex, 4].CellType = "LinkLabelCell"; gridControl1[rowIndex, 4].Text = "Google"; gridControl1[rowIndex, 4].Font.Bold = true; gridControl1[rowIndex, 4].Tag = "http://www.google.com/"; gridControl1[rowIndex, 4].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Col(4)); gridControl1.ColStyles[4].TextColor = Color.Blue; this.gridControl1.DefaultColWidth = 70; this.gridControl1.DefaultGridBorderStyle = GridBorderStyle.Solid; gridControl1.AllowProportionalColumnSizing = true; this.gridControl1.Model.Options.DisplayEmptyRows = true; this.gridControl1.RowHeights[0] = 30; #endregion }
/// <summary> /// Set timer clok to notify the changes /// </summary> private void m_timer_Tick(object sender, EventArgs e) { timerCount++; GridRangeInfo gCells = GridRangeInfo.EmptyRange(); if (oldSize != m_syncGrid.ClientSize) { // Dispose graphics context if size was changed. if (g != null) { g.Dispose(); } g = null; oldSize = m_syncGrid.ClientSize; } if (drawDirectToDC && g == null) { g = m_syncGrid.CreateGridGraphics(); } try { for (int i = 0; i < m_numUpdatesPerTick; i++) { int recNum = rand.Next(m_set.Count - 1); int rowNum = recNum + 1; int col = rand.Next(18) + 1; int colNum = col + 1; object[] drow = (object[])m_set[recNum]; drow[col] = rand.Next(100); GridRangeInfo g1 = GridRangeInfo.Cell(rowNum, colNum); gCells = GridRangeInfo.UnionRange(gCells, g1); // Clear our volatile cache m_syncGrid.ResetVolatileData(); // Handle case when values is change for current cell. if (g1 == m_syncGrid.CurrentCell.RangeInfo) { m_syncGrid.CurrentCell.Model.ResetActiveText(rowNum, colNum); } else { // Draw direct to dc if (drawDirectToDC) { Rectangle bounds = m_syncGrid.RangeInfoToRectangle(g1); if (!bounds.IsEmpty) { // DrawClippedGrid method lets you simply draw the cells at the specified bounds directly to the graphics context. m_syncGrid.DrawClippedGrid(g, bounds); } } } } if (!drawDirectToDC) { m_syncGrid.ResetVolatileData(); m_syncGrid.ViewLayout.Lock(); // Prevent subsequent calls to ViewLayout.Reset method from clearing the layout information. Method was added in 3.1.0.x Rectangle bounds = m_syncGrid.RangeInfoToRectangle(gCells); if (!bounds.IsEmpty) { m_syncGrid.Invalidate(bounds); m_syncGrid.Update(); } m_syncGrid.ViewLayout.Unlock(); } // Insert or remove a row if (insertRemoveCount == 0) { return; } if (toggleInsertRemove > 0 && (timerCount % insertRemoveModulus) == 0) { icount = ++icount % (toggleInsertRemove * 2); shouldInsert = icount <= toggleInsertRemove; Console.WriteLine(m_syncGrid.RowCount); if (shouldInsert) { for (int ri = 0; ri < insertRemoveCount; ri++) { int recNum = rand.Next(m_set.Count - 1); int rowNum = recNum + 1; // Underlying data structure (this could be a datatable or whatever structure // you use behind a virtual grid). // // In this case it is a ArrayList int next = rand.Next(100); object[] row = new object[] { "Hello world", next + 1, next + 2, next + 3, next + 4, next + 5, next + 6, next + 7, next + 8, next + 9, next + 10, next + 11, next + 12, next + 13, next + 14, next + 15, next + 16, next + 17, next + 18, next + 19, next + 20 }; m_set.Insert(recNum, row); // Now that the change was done in the underlying datasource we need // to tell the grid to reflect those changes: m_syncGrid.Model.ResetVolatileData(); // Old way: if (!drawDirectToDC) { m_syncGrid.Rows.OnRangeInserting(new GridRangeInsertingEventArgs(rowNum, 1, null)); m_syncGrid.Rows.OnRangeInserted(new GridRangeInsertedEventArgs(rowNum, 1, null, true)); m_syncGrid.Update(); } else { // Optimized way: Directly calling ScrollWindows, don't let ScrollWindow call Invalidate. if (rowNum < m_syncGrid.TopRowIndex) { if (!allowChangeTopRowWhenInsertBeforeView || !m_syncGrid.ViewLayout.HasPartialVisibleRows) // checks whether the last row is shown and fully visible { // in this case we need to insert at top rowNum = m_syncGrid.TopRowIndex; } else { // If record is inserted before viewable area, simply increase // the top row so that the viewable area stays the same. No // drawing of the screen is needed. m_syncGrid.InternalSetTopRow(m_syncGrid.TopRowIndex + 1); m_syncGrid.UpdateScrollBars(); rowNum = -1; // mark it as handled. if (showNumberedRowHeaders) { // Repaint only row headers - they all change Rectangle rowHeaderBounds = m_syncGrid.RangeInfoToRectangle(GridRangeInfo.Col(0)); m_syncGrid.DrawClippedGrid(g, rowHeaderBounds); } } } if (rowNum != -1) { GridRangeInfo rg = GridRangeInfo.Row(rowNum); Rectangle bounds = m_syncGrid.RangeInfoToRectangle(rg); if (!bounds.IsEmpty) { if (showNumberedRowHeaders) { // don't scroll row header area - leave it as is (only works if all rows have same height ...) bounds.X += m_syncGrid.ColWidths[0]; if (!m_syncGrid.ViewLayout.HasPartialVisibleRows) { // Repaint row headers below last row Rectangle rowHeaderBounds = m_syncGrid.RangeInfoToRectangle(GridRangeInfo.Cells(m_syncGrid.RowCount, 0, m_syncGrid.RowCount, 0)); m_syncGrid.DrawClippedGrid(g, rowHeaderBounds); } } // If rows can have different heights: // m_syncGrid.ViewLayout.Reset(); Rectangle scrollBounds = new Rectangle(bounds.Left, bounds.Top, bounds.Right, m_syncGrid.ClientRectangle.Bottom); m_syncGrid.ScrollWindow(0, bounds.Height, scrollBounds, scrollBounds, false); // don't cause Invalidate being called. m_syncGrid.Model.ResetVolatileData(); // System.Threading.Thread.Sleep(1000); // DrawClippedGrid method lets you simply draw the cells at the specified bounds directly to the graphics context. m_syncGrid.DrawClippedGrid(g, bounds); } m_syncGrid.UpdateScrollBars(); } } } } else { for (int ri = 0; ri < insertRemoveCount; ri++) { int recNum = 5; //rand.Next(m_set.Count - 1); int rowNum = recNum + 1; // Underlying data structure (this could be a datatable or whatever structure // you use behind a virtual grid). // // In this case it is a ArrayList m_set.RemoveAt(recNum); // Now that the change was done in the underlying datasource we need // to tell the grid to reflect those changes: // Old way: if (!drawDirectToDC) { m_syncGrid.Rows.OnRangeRemoving(new GridRangeRemovingEventArgs(rowNum, rowNum + 1)); GridModelInsertRangeOptions iro = new GridModelInsertRangeOptions(); iro.RowColSizes = new int[m_syncGrid.Rows.DefaultSize]; m_syncGrid.Rows.OnRangeRemoved(new GridRangeRemovedEventArgs(rowNum, rowNum + 1, iro, true)); m_syncGrid.Update(); } else { // Optimized way: Directly calling ScrollWindows, don't let ScrollWindow call Invalidate. if (rowNum < m_syncGrid.TopRowIndex) { if (!allowChangeTopRowWhenInsertBeforeView || !m_syncGrid.ViewLayout.HasPartialVisibleRows) // checks whether the last row is shown and fully visible { // in this case we need to insert at top rowNum = m_syncGrid.TopRowIndex; } else { // If record is inserted before viewable area, simply increase // the top row so that the viewable area stays the same. No // drawing of the screen is needed. m_syncGrid.InternalSetTopRow(m_syncGrid.TopRowIndex - 1); m_syncGrid.UpdateScrollBars(); if (showNumberedRowHeaders) { // Repaint only row headers - they all change Rectangle rowHeaderBounds = m_syncGrid.RangeInfoToRectangle(GridRangeInfo.Col(0)); m_syncGrid.DrawClippedGrid(g, rowHeaderBounds); } rowNum = -1; // mark it as handled. } } if (rowNum != -1) { GridRangeInfo rg = GridRangeInfo.Row(rowNum); Rectangle bounds = m_syncGrid.RangeInfoToRectangle(rg); if (!bounds.IsEmpty) { if (showNumberedRowHeaders) { // don't scroll row header area - leave it as is (only works if all rows have same height ...) bounds.X += m_syncGrid.ColWidths[0]; } // If rows can have different heights: // m_syncGrid.ViewLayout.Reset(); Rectangle scrollBounds = new Rectangle(bounds.Left, bounds.Top, bounds.Right, m_syncGrid.ClientRectangle.Bottom); Rectangle scrolledInViewBounds = m_syncGrid.ScrollWindow(0, -bounds.Height, scrollBounds, scrollBounds, false); // don't cause Invalidate being called. m_syncGrid.Model.ResetVolatileData(); // DrawClippedGrid method lets you simply draw the cells at the specified bounds directly to the graphics context. if (!m_syncGrid.ViewLayout.HasPartialVisibleRows) { scrolledInViewBounds = new Rectangle(0, m_syncGrid.ViewLayout.Corner.Y, bounds.Right, bounds.Height); } m_syncGrid.DrawClippedGrid(g, scrolledInViewBounds); } m_syncGrid.UpdateScrollBars(); } } } } } } finally { } }
private void InitializeGrid() { #region CellStyleGridControl gridControl1.Model.Options.FloatCellsMode = GridFloatCellsMode.OnDemandCalculation; GridFontInfo boldFont = new GridFontInfo(); boldFont.Bold = true; boldFont.Size = 11; boldFont.Underline = true; int rowIndex = 2; int colIndex = 1; gridControl1.Rows.DefaultSize += 2; int boldfontRowHeight = gridControl1.Rows.DefaultSize + 6; gridControl1.Model.Options.ControllerOptions = GridControllerOptions.All; gridControl1.Model.Options.DataObjectConsumerOptions = GridDataObjectConsumerOptions.All; GridStyleInfo standard = gridControl1.BaseStylesMap["Standard"].StyleInfo; GridStyleInfo header = gridControl1.BaseStylesMap["Header"].StyleInfo; GridStyleInfo rowHeader = gridControl1.BaseStylesMap["Row Header"].StyleInfo; GridStyleInfo colHeader = gridControl1.BaseStylesMap["Column Header"].StyleInfo; header.Interior = new BrushInfo(SystemColors.Control); rowHeader.Interior = new BrushInfo(SystemColors.Control); standard.Font.Facename = "Arial"; //"Helvetica"; header.Enabled = false; gridControl1.Model.Options.FloatCellsMode = GridFloatCellsMode.OnDemandCalculation; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); gridControl1[rowIndex, 1].Text = "Interior"; gridControl1[rowIndex, 1].Font = boldFont; boldfontRowHeight = gridControl1.RowHeights[rowIndex]; rowIndex++; colIndex = 1; foreach (Color color in new Color[] { Color.Black, Color.Red, Color.Blue, Color.Green, Color.Yellow, Color.DimGray }) { gridControl1[rowIndex, colIndex].Interior = new BrushInfo(color); colIndex++; } rowIndex++; colIndex = 1; foreach (PatternStyle pattern in new PatternStyle[] { PatternStyle.LightVertical, PatternStyle.DarkDownwardDiagonal, PatternStyle.DashedHorizontal, PatternStyle.DottedDiamond, PatternStyle.SmallCheckerBoard, PatternStyle.SmallGrid }) { gridControl1[rowIndex, colIndex].Interior = new BrushInfo(pattern, Color.Black, Color.White); colIndex++; } rowIndex++; colIndex = 1; foreach (GradientStyle pattern in new GradientStyle[] { GradientStyle.BackwardDiagonal, GradientStyle.ForwardDiagonal, GradientStyle.PathEllipse, GradientStyle.PathRectangle, GradientStyle.Vertical, GradientStyle.Horizontal }) { gridControl1[rowIndex, colIndex].Interior = new BrushInfo(pattern, Color.FromArgb(0xde, 0x64, 0x13), Color.Black); //Color.Yellow, Color.Blue); gridControl1[rowIndex, colIndex].CellAppearance = GridCellAppearance.Raised; gridControl1[rowIndex + 1, colIndex].Interior = new BrushInfo(pattern, Color.FromArgb(0x82, 0x2e, 0x1b), Color.White); //Color.Red, Color.White); gridControl1[rowIndex + 1, colIndex].CellAppearance = GridCellAppearance.Sunken; colIndex++; } rowIndex++; rowIndex++; rowIndex++; colIndex = 1; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); gridControl1[rowIndex, 1].Text = "Font"; gridControl1[rowIndex, 1].Font = boldFont; gridControl1.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; foreach (int size in new int[] { 6, 7, 8, 10, 12, 14 }) { gridControl1[rowIndex, colIndex].Font.Size = size; gridControl1[rowIndex, colIndex].Text = size.ToString(); colIndex++; } gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Row(rowIndex)); rowIndex++; colIndex = 1; foreach (FontStyle fontStyle in new FontStyle[] { FontStyle.Bold, FontStyle.Italic, FontStyle.Regular, FontStyle.Strikeout, FontStyle.Underline, FontStyle.Bold | FontStyle.Italic | FontStyle.Regular }) { gridControl1[rowIndex, colIndex].Font.FontStyle = fontStyle; gridControl1[rowIndex, colIndex].Text = System.Enum.Format(typeof(FontStyle), fontStyle, "G"); colIndex++; } rowIndex++; rowIndex++; colIndex = 1; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); gridControl1[rowIndex, 1].Text = "TextColor"; gridControl1[rowIndex, 1].Font = boldFont; gridControl1.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; colIndex = 1; foreach (Color color in new Color[] { Color.Black, Color.Red, Color.Blue, Color.Green, Color.Yellow, Color.DimGray }) { gridControl1[rowIndex, colIndex].TextColor = color; gridControl1[rowIndex, colIndex].Text = ColorConvert.ColorToString(color, true); colIndex++; } rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); gridControl1[rowIndex, 1].Text = "Borders"; gridControl1[rowIndex, 1].Font = boldFont; gridControl1.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; colIndex = 1; foreach (GridBorder border in new GridBorder[] { new GridBorder(GridBorderStyle.Solid, Color.Black), new GridBorder(GridBorderStyle.Dotted, Color.Red), new GridBorder(GridBorderStyle.DashDot, Color.Black), new GridBorder(GridBorderStyle.DashDotDot, Color.Red), new GridBorder(GridBorderStyle.Dashed, Color.Black, GridBorderWeight.Medium), new GridBorder(GridBorderStyle.Dotted, Color.Red, GridBorderWeight.Medium) }) { gridControl1[rowIndex, colIndex].Borders.Bottom = border; gridControl1[rowIndex, colIndex].Borders.Right = border; gridControl1[rowIndex, colIndex].Text = border.ToString(); colIndex++; } rowIndex++; colIndex = 1; foreach (GridBorder border in new GridBorder[] { new GridBorder(GridBorderStyle.Dashed, Color.Black, GridBorderWeight.Thick), new GridBorder(GridBorderStyle.Dotted, Color.Red, GridBorderWeight.Thick), new GridBorder(GridBorderStyle.DashDot, Color.Black, GridBorderWeight.Medium), new GridBorder(GridBorderStyle.DashDotDot, Color.Red, GridBorderWeight.Medium), new GridBorder(GridBorderStyle.Solid, Color.Black, GridBorderWeight.Thick), new GridBorder(GridBorderStyle.Solid, Color.Red, GridBorderWeight.Medium) }) { gridControl1[rowIndex, colIndex].Borders.Bottom = border; gridControl1[rowIndex, colIndex].Borders.Right = border; gridControl1[rowIndex, colIndex].Text = border.ToString(); colIndex++; } rowIndex++; rowIndex++; colIndex = 1; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2)); gridControl1[rowIndex, 1].Text = "Orientation"; gridControl1[rowIndex, 1].Font = boldFont; gridControl1.RowHeights[rowIndex] = boldfontRowHeight; rowIndex++; foreach (int orientation in new int[] { 0, 45, 60, 90, 180, -90 }) { GridStyleInfo style1 = gridControl1[rowIndex, colIndex]; // style1 is a direct reference to gridControl1[rowIndex, colIndex]; // changes will be propagated back to GridData style1.HorizontalAlignment = GridHorizontalAlignment.Center; style1.VerticalAlignment = GridVerticalAlignment.Middle; GridFontInfo font = style1.Font; font.Orientation = orientation; font.Bold = true; style1.Text = "Angle = " + font.Orientation.ToString(); colIndex++; } gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Row(rowIndex)); rowIndex++; rowIndex++; colIndex = 1; gridControl1.CurrentCell.MoveTo(2, 2); this.gridControl1.DefaultRowHeight = 18; this.gridControl1.DefaultColWidth = 70; this.gridControl1.DefaultGridBorderStyle = GridBorderStyle.Solid; #endregion #region StyleObject Grid //change the header's BackColor gridControl2.BaseStylesMap["Header"].StyleInfo.BackColor = Color.FromArgb(238, 240, 246); gridControl2.BaseStylesMap["Row Header"].StyleInfo.BackColor = Color.FromArgb(238, 240, 246); //add a new basestyle gridBaseStyle1 = new GridBaseStyle("BackColorTest", false); gridControl2.BaseStylesMap["BackColorTest"].StyleInfo.BackColor = Color.SkyBlue; #endregion }
/// <summary> /// Form Constructor /// </summary> public MultipleViewForm() { // // Required for Windows Form Designer support // InitializeComponent(); this.GridSettings(); #region Buffer text gridControl1.Model.TextDataExchange.PasteTextFromBuffer( "1\tDavolio Nancy\r\n" + "2\tFuller Andrew\r\n"+ "3\tLeverling Janet\r\n"+ "4\tPeacock Margaret\r\n" + "5\tBuchanan Steven\r\n"+ "6\tSuyama Michael\r\n"+ "7\tKing Robert\r\n"+ "8\tCallahan Laura\r\n"+ "9\tDodsworth Anne\r\n", GridRangeInfo.Cell(1, 1), int.MaxValue); #endregion #region Style Info GridStyleInfo standard = gridControl1.BaseStylesMap["Standard"].StyleInfo; //System.IO.Stream strm = null; ImageList imageList = new ImageList(); System.IO.Stream strm = null; string iconName = "MultipleViews.user.ico"; strm = this.GetType().Assembly.GetManifestResourceStream(iconName); Icon icon = new Icon(strm); imageList.Images.Add(icon.ToBitmap()); iconName = "MultipleViews.userH.ico"; strm = this.GetType().Assembly.GetManifestResourceStream(iconName); icon = new Icon(strm); imageList.Images.Add(icon.ToBitmap()); iconName = "MultipleViews.userJ.ico"; strm = this.GetType().Assembly.GetManifestResourceStream(iconName); icon = new Icon(strm); imageList.Images.Add(icon.ToBitmap()); standard.ImageList = imageList; int rowIndex = 1; int colIndex = 2; gridControl1[rowIndex++, colIndex].ImageIndex = 1; gridControl1[rowIndex++, colIndex].ImageIndex = 2; gridControl1[rowIndex++, colIndex].ImageIndex = 0; gridControl1[rowIndex++, colIndex].ImageIndex = 1; gridControl1[rowIndex++, colIndex].ImageIndex = 1; gridControl1[rowIndex++, colIndex].ImageIndex = 2; gridControl1[rowIndex++, colIndex].ImageIndex = 2; gridControl1[rowIndex++, colIndex].ImageIndex = 0; gridControl1[rowIndex++, colIndex].ImageIndex = 1; //gridControl1.Model.Options.DataObjectConsumerOptions = GridDataObjectConsumerOptions.Styles; gridControl1.DataObjectConsumerOptions = GridDataObjectConsumerOptions.All; GridStyleInfo style; style = new GridStyleInfo(); style.Interior = new BrushInfo(Color.White); style.TextColor = Color.FromArgb(0x82, 0x2e, 0x1b); gridControl1.ChangeCells(GridRangeInfo.Cells(1, 1, 9, 3), style); style = new GridStyleInfo(); style.HorizontalAlignment = GridHorizontalAlignment.Right; style.CellValueType = typeof(int); style.Format = "000"; gridControl1.ChangeCells(GridRangeInfo.Cells(1, 1, 9, 1), style); gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cells(1, 1, 9, 3)); gridControl1.CommandStack.Enabled = true; // Make second grid controls share the same model. #endregion #region Properties this.gridControl1.DefaultRowHeight = 18; this.gridControl1.DefaultColWidth = 70; this.gridControl1.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Office2007Blue; this.gridControl1.Properties.GridLineColor = Color.FromArgb(208, 215, 229); this.gridControl1.DefaultGridBorderStyle = Syncfusion.Windows.Forms.Grid.GridBorderStyle.Solid; style = this.gridControl1.BaseStylesMap["Header"].StyleInfo; style.TextColor = System.Drawing.Color.MidnightBlue; style.Font.Facename = "Verdana"; style = this.gridControl1.BaseStylesMap["Standard"].StyleInfo; style.TextColor = System.Drawing.Color.MidnightBlue; style.Font.Facename = "Verdana"; gridControl2.Model = gridControl1.Model; this.gridControl1.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro; this.gridControl1.Model.ColWidths.ResizeToFit(GridRangeInfo.Table()); this.gridControl2.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro; #endregion }
private void InitializeGrid() { #region "Style declaration" //headerStyle this.gridControl1.DefaultRowHeight = 22; GridStyleInfo headerstyle = new GridStyleInfo(); headerstyle.Font.Size = 12; headerstyle.Font.Bold = true; headerstyle.VerticalAlignment = GridVerticalAlignment.Middle; headerstyle.HorizontalAlignment = GridHorizontalAlignment.Center; headerstyle.CellType = GridCellTypeName.Static; //subheaderstyle GridStyleInfo subheaderstyle = new GridStyleInfo(); subheaderstyle.Font.Bold = true; subheaderstyle.VerticalAlignment = GridVerticalAlignment.Middle; subheaderstyle.HorizontalAlignment = GridHorizontalAlignment.Center; subheaderstyle.CellType = GridCellTypeName.Static; GridStyleInfo valuestyle = new GridStyleInfo(); valuestyle.BackColor = SystemColors.Menu; valuestyle.TextColor = Color.Black; valuestyle.VerticalAlignment = GridVerticalAlignment.Middle; valuestyle.HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.FloatCellsMode = GridFloatCellsMode.BeforeDisplayCalculation; #endregion gridControl1.BeginUpdate(); #region "CellButton" int rowIndex = 1, colIndex = 5; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Cell Buttons"; gridControl1.CellModels.Add("DragButton", new DragButtonCellModel(gridControl1.Model)); rowIndex = 4; gridControl1[rowIndex, 2].Text = "Press and Drag Button"; gridControl1[rowIndex, 2].Font.Bold = true; gridControl1[rowIndex, 4].CellType = "DragButton"; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 2, rowIndex, 3)); gridControl1.CellModels.Add("EllipsisText", new EllipsisCellModel(gridControl1.Model)); gridControl1[rowIndex, 8].Text = "Browse Me"; gridControl1[rowIndex, 8].Font.Bold = true; gridControl1[rowIndex, 8].CellType = "EllipsisText"; gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cells(3, 6, 10, 6)); gridControl1.Model.CellModels.Add("MultipleButton", new MultipleButtonGridCell.MultipleButtonCellModel(gridControl1.Model)); rowIndex = 6; gridControl1[rowIndex, 2].Text = "MultiButtonCell"; gridControl1[rowIndex, 2].Font.Bold = true; gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cells(6, 2, 8, 2)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(6, 4, 6, 5)); gridControl1.QueryCellInfo += new GridQueryCellInfoEventHandler(gridControl1_QueryCellInfo); #endregion #region "OleContainerCell" colIndex = 2; RegisterCellModel.GridCellType(this.gridControl1, CustomCellTypes.OleContainerCell); rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1.CellModels.Add("LinkLabelCell", new LinkLabelCellModel(gridControl1.Model)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "OLEContainer Cell"; rowIndex += 2; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "Click the image to open the file with its default file handler"; rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 2, colIndex)); gridControl1[rowIndex, colIndex].CellType = CustomCellTypes.OleContainerCell.ToString(); gridControl1[rowIndex, colIndex].Description = GetIconFile(@"Data\DocIO\SalesInvoiceDemo.doc"); colIndex = 4; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 2, colIndex)); gridControl1[rowIndex, colIndex].CellType = CustomCellTypes.OleContainerCell.ToString(); gridControl1[rowIndex, colIndex].Description = GetIconFile(@"Data\XlsIO\BudgetPlanner.xls"); colIndex = 6; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 2, colIndex)); gridControl1[rowIndex, colIndex].CellType = CustomCellTypes.OleContainerCell.ToString(); gridControl1[rowIndex, colIndex].Description = GetIconFile(@"Data\PDF\CaseStudy.pdf"); colIndex = 2; rowIndex += 4; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 2, colIndex)); gridControl1[rowIndex, colIndex].CellType = CustomCellTypes.OleContainerCell.ToString(); gridControl1[rowIndex, colIndex].Description = GetIconFile(@"Data\DocIO\Arabic.txt"); colIndex = 4; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 2, colIndex)); gridControl1[rowIndex, colIndex].CellType = CustomCellTypes.OleContainerCell.ToString(); gridControl1[rowIndex, colIndex].Description = GetIconFile(@"Common\Images\Grid\CustomBorder\back3.jpg"); colIndex = 6; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 2, colIndex)); gridControl1[rowIndex, colIndex].CellType = CustomCellTypes.OleContainerCell.ToString(); gridControl1[rowIndex, colIndex].Description = @"http://www.syncfusion.com/"; gridControl1[13, 8] = subheaderstyle; gridControl1[13, 8].Text = "Preview"; gridControl1[13, 8].BackColor = Color.LightGray; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(14, 8, 16, 8)); gridControl1[17, 8].CellType = GridCellTypeName.PushButton; gridControl1[17, 8].Description = "Select a file for preview"; this.gridControl1.Model.ColWidths[8] = 127; rowIndex++; colIndex = 5; #endregion #region "SliderCells" rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Slider Cells"; gridControl1.CellModels.Add("Slider", new SliderCellModel(gridControl1.Model)); rowIndex += 3; SliderStyleProperties tsp = new SliderStyleProperties(new GridStyleInfo(gridControl1.TableStyle)); tsp.Orientation = Orientation.Horizontal; GridStyleInfo style; SliderStyleProperties sp; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex + 1, 4)); style = gridControl1[rowIndex, 3]; sp = new SliderStyleProperties(style); style.CellType = "Slider"; sp.Maximum = 60; sp.Minimum = 0; sp.TickFrequency = 8; sp.LargeChange = 16; sp.SmallChange = 4; sp.Orientation = Orientation.Horizontal; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 5, rowIndex + 1, 5)); style = gridControl1[rowIndex, 5]; sp = new SliderStyleProperties(style); style.CellType = "Slider"; sp.Maximum = 40; sp.Minimum = 0; sp.TickFrequency = 8; sp.LargeChange = 16; sp.SmallChange = 4; sp.Orientation = Orientation.Horizontal; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 6, rowIndex + 7, 6)); style = gridControl1[rowIndex, 6]; sp = new SliderStyleProperties(style); style.CellType = "Slider"; sp.Maximum = 40; sp.Minimum = 0; sp.TickFrequency = 8; sp.LargeChange = 16; sp.SmallChange = 4; sp.Orientation = Orientation.Vertical; gridControl1.EndUpdate(true); #endregion #region "ButtonEdit Cells" rowIndex = 31; #if HELPERCLASS // Added from the source of Syncfusion.GridHelperClasses RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.ButtonEdit); #else this.gridControl1.CellModels.Add("ButtonEdit", new ButtonEditCellModel(this.gridControl1.Model)); #endif gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Button Edit Cells"; rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "ButtonEdit displaying common images and getting from file"; rowIndex++; rowIndex++; gridControl1[rowIndex, 2].FloatCell = true; gridControl1[rowIndex, 2].Text = "Common Images"; gridControl1[rowIndex, 2].TextColor = Color.Black; gridControl1[rowIndex, 4].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(this.gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = Syncfusion.GridHelperClasses.ButtonType.Check; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Check; #endif gridControl1[rowIndex, 5].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Down; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Down; #endif gridControl1[rowIndex, 6].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Undo; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Undo; #endif rowIndex++; rowIndex++; gridControl1[rowIndex, 2].FloatCell = true; gridControl1[rowIndex, 2].Text = "From File"; gridControl1[rowIndex, 2].TextColor = Color.Black; gridControl1[rowIndex, 4].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Image; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Image; #endif Image bmp = Image.FromFile(@"..//..//delete.png"); bsp.ButtonEditInfo.Image = bmp; gridControl1[rowIndex, 5].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Image; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Image; #endif bmp = Image.FromFile(@"..//..//about.png"); bsp.ButtonEditInfo.Image = bmp; gridControl1[rowIndex, 6].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Image; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Image; #endif bmp = Image.FromFile(@"..//..//disk_blue.png"); bsp.ButtonEditInfo.Image = bmp; rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "ButtonEdit cell with formatting options like textcolor, alignment, borders.."; rowIndex++; rowIndex++; gridControl1[rowIndex, 2].FloatCell = true; gridControl1[rowIndex, 2].Text = "With Colors"; gridControl1[rowIndex, 2].TextColor = Color.Black; gridControl1[rowIndex, 4].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #endif bsp.ButtonEditInfo.ForceBackColor = true; bsp.ButtonEditInfo.BackColor = Color.LightGreen; gridControl1[rowIndex, 5].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #endif bsp.ButtonEditInfo.ForceBackColor = true; bsp.ButtonEditInfo.BackColor = Color.LightPink; gridControl1[rowIndex, 6].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #endif bsp.ButtonEditInfo.ForceBackColor = true; bsp.ButtonEditInfo.BackColor = Color.LightSkyBlue; rowIndex++; rowIndex++; gridControl1[rowIndex, 2].FloatCell = true; gridControl1[rowIndex, 2].Text = "Text Alignment"; gridControl1[rowIndex, 2].TextColor = Color.Black; gridControl1[rowIndex, 4].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #endif bsp.ButtonEditInfo.Width = 50; bsp.ButtonEditInfo.Text = "Sync"; bsp.ButtonEditInfo.HorizontalAlignment = GridHorizontalAlignment.Right; bsp.ButtonEditInfo.VerticalAlignment = GridVerticalAlignment.Top; gridControl1[rowIndex, 5].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #endif bsp.ButtonEditInfo.Width = 50; bsp.ButtonEditInfo.Text = "Sync"; bsp.ButtonEditInfo.HorizontalAlignment = GridHorizontalAlignment.Left; bsp.ButtonEditInfo.VerticalAlignment = GridVerticalAlignment.Bottom; gridControl1[rowIndex, 6].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #endif bsp.ButtonEditInfo.Width = 50; bsp.ButtonEditInfo.Text = "Sync"; bsp.ButtonEditInfo.HorizontalAlignment = GridHorizontalAlignment.Center; bsp.ButtonEditInfo.VerticalAlignment = GridVerticalAlignment.Middle; rowIndex++; rowIndex++; gridControl1[rowIndex, 2].FloatCell = true; gridControl1[rowIndex, 2].Text = "Button Alignment with Left & Right"; gridControl1[rowIndex, 2].TextColor = Color.Black; gridControl1.Model.RowHeights[rowIndex] = 20; gridControl1[rowIndex, 5].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Leftend; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Leftend; #endif bsp.ButtonEditInfo.IsLeft = true; gridControl1[rowIndex, 6].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Rightend; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Rightend; #endif bsp.ButtonEditInfo.IsLeft = false; rowIndex++; rowIndex++; gridControl1[rowIndex, 2].FloatCell = true; gridControl1[rowIndex, 2].Text = "Border around button"; gridControl1[rowIndex, 2].TextColor = Color.Black; gridControl1[rowIndex, 5].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 5]); #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 5]); #endif bsp.ButtonEditInfo.Width = 30; #if HELPERCLASS ((Syncfusion.GridHelperClasses.ButtonEditCellModel) this.gridControl1.CellModels["ButtonEdit"]).GridDrawButtonFace += new Syncfusion.GridHelperClasses.ButtonEditCellModel.GridDrawButtonFaceEventHandler(Form1_GridDrawButtonFace); #else ((ButtonEditCellModel)this.gridControl1.CellModels["ButtonEdit"]).GridDrawButtonFace += new ButtonEditCellModel.GridDrawButtonFaceEventHandler(Form1_GridDrawButtonFace); #endif #endregion #region "LinkLabel" rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); //gridControl1.CellModels.Add("LinkLabelCell", new LinkLabelCellModel(gridControl1.Model)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Link Label Cells"; rowIndex += 3; gridControl1[rowIndex, colIndex].CellType = "LinkLabelCell"; gridControl1[rowIndex, colIndex].Text = "Syncfusion, Inc."; gridControl1[rowIndex, colIndex].Font.Bold = true; gridControl1[rowIndex, colIndex].Tag = "http://www.syncfusion.com"; gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].CellType = "LinkLabelCell"; gridControl1[rowIndex, colIndex].Text = "Windows Forms FAQ"; gridControl1[rowIndex, colIndex].Font.Bold = true; gridControl1[rowIndex, colIndex].Tag = "http://www.syncfusion.com/support/forums/grid-windows"; gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].CellType = "LinkLabelCell"; gridControl1[rowIndex, colIndex].Text = "Microsoft Windows Forms"; gridControl1[rowIndex, colIndex].Font.Bold = true; gridControl1[rowIndex, colIndex].Tag = "http://windowsforms.net/"; gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].CellType = "LinkLabelCell"; gridControl1[rowIndex, colIndex].Text = "MSDN"; gridControl1[rowIndex, colIndex].Font.Bold = true; gridControl1[rowIndex, colIndex].Tag = "http://msdn.microsoft.com"; gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cells(9, 5, 17, 5)); #endregion this.gridControl1.Model.Options.DisplayEmptyColumns = true; this.gridControl1.Model.Options.DisplayEmptyRows = true; gridControl1.EndUpdate(true); gridControl1.Refresh(); }
private void InitGridList() { var gridListProperties = new List <GridListControlProperties>(); gridListProperties.Add(new GridListControlProperties { Header = "No", Width = 30 }); gridListProperties.Add(new GridListControlProperties { Header = "Tanggal", Width = 80 }); gridListProperties.Add(new GridListControlProperties { Header = "Produk", Width = 250 }); gridListProperties.Add(new GridListControlProperties { Header = "Penambahan", Width = 80 }); gridListProperties.Add(new GridListControlProperties { Header = "Penambahan", Width = 80 }); gridListProperties.Add(new GridListControlProperties { Header = "Pengurangan", Width = 80 }); gridListProperties.Add(new GridListControlProperties { Header = "Pengurangan", Width = 80 }); gridListProperties.Add(new GridListControlProperties { Header = "Alasan Penyesuaian", Width = 350 }); gridListProperties.Add(new GridListControlProperties { Header = "Keterangan" }); GridListControlHelper.InitializeGridListControl <PenyesuaianStok>(this.gridList, _listOfPenyesuaianStok, gridListProperties, false, additionalRowCount: 1); this.gridList.Grid.Model.RowHeights[1] = 25; this.gridList.Grid.Model.Rows.FrozenCount = 1; this.gridList.Grid.PrepareViewStyleInfo += delegate(object sender, GridPrepareViewStyleInfoEventArgs e) { var subHeaderHargaJual = new string[] { "Stok Etalase", "Stok Gudang", "Stok Etalase", "Stok Gudang" }; if (e.ColIndex > 3 && e.RowIndex == 1) { var colIndex = 4; foreach (var header in subHeaderHargaJual) { if (colIndex == e.ColIndex) { e.Style.Text = header; } colIndex++; } } }; if (_listOfPenyesuaianStok.Count > 0) { this.gridList.SetSelected(1, true); } // merge cell var column = 1; // kolom no this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); column = 2; // tanggal this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); column = 3; // produk this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); column = 4; // kolom penambahan stok etalase dan gudang this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 0, column + 1)); column = 6; // kolom pengurangan stok etalase dan gudang this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 0, column + 1)); column = 8; // alasan penyesuaian this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); column = 9; // keterangan this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); var headerStyle = this.gridList.Grid.BaseStylesMap["Column Header"].StyleInfo; headerStyle.CellType = GridCellTypeName.Header; this.gridList.Grid.QueryCellInfo += delegate(object sender, GridQueryCellInfoEventArgs e) { if (e.RowIndex == 1) { if (e.ColIndex > 3) { e.Style.ModifyStyle(headerStyle, StyleModifyType.ApplyNew); } // we handled it, let the grid know e.Handled = true; } if (_listOfPenyesuaianStok.Count > 0) { if (e.RowIndex > 1) { var rowIndex = e.RowIndex - 2; if (rowIndex < _listOfPenyesuaianStok.Count) { var penyesuaianStok = _listOfPenyesuaianStok[rowIndex]; switch (e.ColIndex) { case 1: e.Style.CellValue = e.RowIndex - 1; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; break; case 2: e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; e.Style.CellValue = DateTimeHelper.DateToString(penyesuaianStok.tanggal); break; case 3: e.Style.CellValue = penyesuaianStok.Produk.nama_produk; break; case 4: e.Style.CellValue = penyesuaianStok.penambahan_stok; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; break; case 5: e.Style.CellValue = penyesuaianStok.penambahan_stok_gudang; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; break; case 6: e.Style.CellValue = penyesuaianStok.pengurangan_stok; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; break; case 7: e.Style.CellValue = penyesuaianStok.pengurangan_stok_gudang; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; break; case 8: e.Style.CellValue = penyesuaianStok.AlasanPenyesuaianStok.alasan; break; case 9: e.Style.CellValue = penyesuaianStok.keterangan; break; default: break; } // we handled it, let the grid know e.Handled = true; } } } }; }
private void Form1_Load(object sender, System.EventArgs e) { this.gridGroupingControl1.TableModel.Options.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshCell; this.gridGroupingControl1.TableModel.Options.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.GrayWhenLostFocus; this.gridGroupingControl1.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Cells(1, 1, this.gridGroupingControl1.TableModel.RowCount, this.gridGroupingControl1.TableModel.ColCount)); }
private void InitGridList() { var gridListProperties = new List <GridListControlProperties>(); gridListProperties.Add(new GridListControlProperties { Header = "No", Width = 30 }); gridListProperties.Add(new GridListControlProperties { Header = "Tanggal", Width = 100 }); gridListProperties.Add(new GridListControlProperties { Header = "Tempo", Width = 100 }); gridListProperties.Add(new GridListControlProperties { Header = "Nota", Width = 100 }); gridListProperties.Add(new GridListControlProperties { Header = "Customer", Width = _pengaturanUmum.jenis_printer == JenisPrinter.InkJet ? 180 : 260 }); gridListProperties.Add(new GridListControlProperties { Header = "Keterangan", Width = 350 }); gridListProperties.Add(new GridListControlProperties { Header = "Piutang", Width = 100 }); gridListProperties.Add(new GridListControlProperties { Header = "Sisa Piutang", Width = 100 }); gridListProperties.Add(new GridListControlProperties { Header = "Histori Pembayaran", Width = 80 }); if (_pengaturanUmum.jenis_printer == JenisPrinter.InkJet) { gridListProperties.Add(new GridListControlProperties { Header = "Cetak Nota/Label", Width = 80 }); gridListProperties.Add(new GridListControlProperties { Header = "" }); } else { gridListProperties.Add(new GridListControlProperties { Header = "Cetak Nota", Width = 80 }); } GridListControlHelper.InitializeGridListControl <JualProduk>(this.gridList, _listOfJual, gridListProperties, false, rowHeight: 40); if (_pengaturanUmum.jenis_printer == JenisPrinter.InkJet) { // merge header kolom cetak nota/label this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, 10, 0, 11)); } if (_listOfJual.Count > 0) { this.gridList.SetSelected(0, true); } this.gridList.Grid.PushButtonClick += delegate(object sender, GridCellPushButtonClickEventArgs e) { if (e.RowIndex > 0) { var index = e.RowIndex - 1; switch (e.ColIndex) { case 9: // histori pembayaran using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { var jual = _listOfJual[index]; IPembayaranPiutangProdukBll bll = new PembayaranPiutangProdukBll(_log); var listOfHistoriPembayaran = bll.GetHistoriPembayaran(jual.jual_id); if (listOfHistoriPembayaran.Count > 0) { var frmHistoriPembayaran = new FrmLookupHistoriPembayaran("Histori Pembayaran Piutang", jual, listOfHistoriPembayaran); frmHistoriPembayaran.ShowDialog(); } else { MsgHelper.MsgInfo("Belum ada informasi histori pembayaran"); } } break; case 10: // cetak nota jual using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { var jual = _listOfJual[index]; switch (this._pengaturanUmum.jenis_printer) { case JenisPrinter.DotMatrix: if (MsgHelper.MsgKonfirmasi("Apakah proses pencetakan ingin dilanjutkan ?")) { CetakNotaDotMatrix(jual); } break; case JenisPrinter.MiniPOS: if (MsgHelper.MsgKonfirmasi("Apakah proses pencetakan ingin dilanjutkan ?")) { CetakNotaMiniPOS(jual); } break; default: var frmCetakNota = new FrmPreviewNotaPenjualan("Preview Nota Penjualan", jual); frmCetakNota.ShowDialog(); break; } } break; case 11: // cetak label nota jual using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { var jual = _listOfJual[index]; var frmCetakLabelNota = new FrmPreviewLabelNotaPenjualan("Preview Label Nota Penjualan", jual); frmCetakLabelNota.ShowDialog(); } break; default: break; } } }; this.gridList.Grid.QueryCellInfo += delegate(object sender, GridQueryCellInfoEventArgs e) { if (_listOfJual.Count > 0) { if (e.RowIndex > 0) { var rowIndex = e.RowIndex - 1; if (rowIndex < _listOfJual.Count) { double totalNota = 0; var jual = _listOfJual[rowIndex]; if (jual != null) { totalNota = jual.grand_total; } var isRetur = jual.retur_jual_id != null; var oldStyleBackColor = e.Style.BackColor; if (isRetur) { e.Style.BackColor = Color.Red; } switch (e.ColIndex) { case 1: var noUrut = (_pageNumber - 1) * _pageSize + e.RowIndex; e.Style.CellValue = noUrut; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; break; case 2: e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; e.Style.CellValue = DateTimeHelper.DateToString(jual.tanggal); break; case 3: e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; e.Style.CellValue = DateTimeHelper.DateToString(jual.tanggal_tempo); break; case 4: e.Style.CellValue = jual.nota; break; case 5: if (jual.Customer != null) { SetWilayahCustomer(jual.Customer); e.Style.CellValue = jual.Customer.nama_customer; } break; case 6: e.Style.CellValue = jual.keterangan; break; case 7: e.Style.HorizontalAlignment = GridHorizontalAlignment.Right; e.Style.CellValue = NumberHelper.NumberToString(totalNota); break; case 8: e.Style.HorizontalAlignment = GridHorizontalAlignment.Right; e.Style.CellValue = NumberHelper.NumberToString(totalNota - jual.total_pelunasan); break; case 9: // button history pembayaran e.Style.Enabled = jual.tanggal_tempo != null; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; e.Style.CellType = GridCellTypeName.PushButton; e.Style.BackColor = oldStyleBackColor; e.Style.Description = "Cek Histori"; break; case 10: // button cetak nota e.Style.Enabled = jual.Customer != null; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; e.Style.CellType = GridCellTypeName.PushButton; e.Style.BackColor = oldStyleBackColor; e.Style.Description = "Cetak Nota"; break; case 11: // button cetak label nota if (_pengaturanUmum.jenis_printer == JenisPrinter.InkJet) { e.Style.Enabled = jual.Customer != null; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; e.Style.CellType = GridCellTypeName.PushButton; e.Style.BackColor = oldStyleBackColor; e.Style.Description = "Cetak Label Nota"; } break; default: break; } // we handled it, let the grid know e.Handled = true; } } } }; }
private void InitializeGrid() { #region Style declaration this.gridControl1.DefaultRowHeight = 18; GridStyleInfo headerstyle = new GridStyleInfo(); headerstyle.Font.Size = 12; headerstyle.Font.Bold = true; headerstyle.TextColor = Color.Black; headerstyle.VerticalAlignment = GridVerticalAlignment.Middle; headerstyle.HorizontalAlignment = GridHorizontalAlignment.Center; headerstyle.CellType = GridCellTypeName.Static; GridStyleInfo subheaderstyle = new GridStyleInfo(); subheaderstyle.Font.Bold = true; subheaderstyle.VerticalAlignment = GridVerticalAlignment.Middle; subheaderstyle.HorizontalAlignment = GridHorizontalAlignment.Center; subheaderstyle.CellType = GridCellTypeName.Static; GridStyleInfo valuestyle = new GridStyleInfo(); valuestyle.BackColor = SystemColors.Menu; valuestyle.TextColor = Color.Black; valuestyle.VerticalAlignment = GridVerticalAlignment.Middle; valuestyle.HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.FloatCellsMode = GridFloatCellsMode.BeforeDisplayCalculation; gridControl1.Model.EnableLegacyStyle = true; int rowIndex = 1, colIndex = 2; #endregion #region ComboBoxCell (1 to 15) gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "DropDown Cells"; rowIndex += 3; ArrayList USStates = new ArrayList(); USStates.Add(new USState("Alabama", "AL", 0)); USStates.Add(new USState("Alaska", "AK", 1)); USStates.Add(new USState("Arizona", "AZ", 2)); USStates.Add(new USState("Arkansas", "AS", 3)); USStates.Add(new USState("California", "CA", 4)); USStates.Add(new USState("NewJersey", "NJ", 5)); USStates.Add(new USState("Seattle", "ST", 6)); gridControl1[rowIndex, colIndex].FloatCell = true; gridControl1.Model.ColWidths[5] = 120; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex, 4)); gridControl1[rowIndex, 3].Text = "ComboBox Cells"; gridControl1[rowIndex, 3].CellType = GridCellTypeName.Static; gridControl1[rowIndex, 5].Text = "Select your choice"; gridControl1[rowIndex, 5].CellType = GridCellTypeName.ComboBox; gridControl1[rowIndex, 5].DataSource = USStates; gridControl1[rowIndex, 5].DisplayMember = "LongName"; gridControl1[rowIndex, 5].ValueMember = "ShortName"; rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex, 4)); gridControl1[rowIndex, 3].Text = "GridListControl Cells"; gridControl1[rowIndex, 3].CellType = GridCellTypeName.Static; gridControl1[rowIndex, 5].Text = "Select your choice"; gridControl1[rowIndex, 5].CellType = GridCellTypeName.GridListControl; gridControl1[rowIndex, 5].DataSource = USStates; gridControl1[rowIndex, 5].DisplayMember = "LongName"; gridControl1[rowIndex, 5].ValueMember = "ShortName"; rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex, 4)); gridControl1[rowIndex, 3].Text = "DropDown Grid Cells"; gridControl1[rowIndex, 3].CellType = GridCellTypeName.Static; gridControl1[rowIndex, 5].CellType = GridCellTypeName.DropDownGrid; //gridControl1[rowIndex, 5].DataSource = USStates; //gridControl1[rowIndex, 5].DisplayMember = "LongName"; //gridControl1[rowIndex, 5].ValueMember = "ShortName"; rowIndex += 2; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex, 7)); gridControl1[rowIndex, 3].CellType = GridCellTypeName.CheckBox; gridControl1[rowIndex, 3].Description = "For themed scrollbars in DropDown"; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex + 3, 7)); gridControl1[rowIndex, 3].CellType = GridCellTypeName.Static; gridControl1[rowIndex, 3].Text = "Dropdown can use the themed scrollbars only when. \n\n 1. LegacyStyles should be disabled which will applies the ColorStyles \n 2. \"EnableGridListControlInComboBox\" property should be enabled."; gridControl1[rowIndex, 3].FloatCell = true; for (int i = rowIndex; i <= rowIndex + 3; i++) { gridControl1.HideRows[i] = true; } rowIndex = 14; #endregion #region RadioButtons ( 16 to 18) rowIndex += 2; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Radio Buttons"; rowIndex += 2; StringCollection sc = new StringCollection(); sc.AddRange(new String[] { "Button 0", "Disabled/disabled", "Button 2", "Button 3" }); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount - 1)); this.gridControl1[rowIndex, 1].ChoiceList = sc; this.gridControl1[rowIndex, 1].CellType = "RadioButton"; this.gridControl1[rowIndex, 1].Font.Bold = true; this.gridControl1[rowIndex, 1].CellValue = 0; //selected button this.gridControl1[rowIndex, 1].TextAlign = GridTextAlign.Left; //where descriptions are this.gridControl1[rowIndex, 1].TextMargins.Left = 5; this.gridControl1[rowIndex, 1].TextMargins.Right = 5; #endregion #region PushButtons 20 to 23 rowIndex += 2; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Push Buttons"; rowIndex += 3; gridControl1.RowHeights[rowIndex] = 22; gridControl1[rowIndex, colIndex].Description = "Raised"; gridControl1[rowIndex, colIndex].CellType = GridCellTypeName.PushButton; gridControl1[rowIndex, colIndex].CellAppearance = GridCellAppearance.Raised; gridControl1[rowIndex, colIndex].Font.Size = 8; gridControl1[rowIndex, colIndex + 2].Description = "Flat"; gridControl1[rowIndex, colIndex + 2].CellType = GridCellTypeName.PushButton; gridControl1[rowIndex, colIndex + 2].Font.Size = 8; gridControl1[rowIndex, colIndex + 4].Description = "Sunken"; gridControl1[rowIndex, colIndex + 4].CellType = GridCellTypeName.PushButton; gridControl1[rowIndex, colIndex + 4].Font.Size = 8; gridControl1[rowIndex, colIndex + 4].CellAppearance = GridCellAppearance.Sunken; #endregion #region CheckBox cells rowIndex += 2; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "CheckBox Cells"; rowIndex += 3; gridControl1.TableStyle.CheckBoxOptions = new GridCheckBoxCellInfo("True", "False", "", false); gridControl1[rowIndex, colIndex].CellValue = false; gridControl1[rowIndex, colIndex].Description = "Click Me"; gridControl1[rowIndex, colIndex].CellType = "CheckBox"; gridControl1[rowIndex, colIndex].TriState = false; gridControl1[rowIndex, colIndex + 2].CellValue = true; gridControl1[rowIndex, colIndex + 2].CellType = "CheckBox"; gridControl1[rowIndex, colIndex + 2].TriState = true; gridControl1[rowIndex, colIndex + 2].Description = "TriState"; gridControl1[rowIndex, colIndex + 2].VerticalAlignment = GridVerticalAlignment.Middle; gridControl1[rowIndex, colIndex + 4].Text = "True"; gridControl1[rowIndex, colIndex + 4].CellType = "CheckBox"; gridControl1[rowIndex, colIndex + 4].TriState = false; gridControl1[rowIndex, colIndex + 4].Description = "Disabled"; gridControl1[rowIndex, colIndex + 4].Enabled = false; gridControl1[rowIndex, colIndex + 4].VerticalAlignment = GridVerticalAlignment.Bottom; #endregion #region Header cells rowIndex += 2; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Header Cells"; rowIndex += 3; gridControl1[rowIndex, colIndex].Text = "Header"; gridControl1[rowIndex, colIndex].CellType = GridCellTypeName.Header; gridControl1[rowIndex, colIndex + 2].Text = "Column Header"; gridControl1[rowIndex, colIndex + 2].CellType = GridCellTypeName.Header; gridControl1[rowIndex, colIndex + 4].Text = "Row Header"; gridControl1[rowIndex, colIndex + 4].CellType = GridCellTypeName.Header; gridControl1.ColWidths[4] = 90; gridControl1.ColWidths[6] = 90; //gridControl1.ColWidths[8] = 90; #endregion this.textColorSettings(Color.Black); }
private void InitGridList() { var gridListProperties = new List <GridListControlProperties>(); gridListProperties.Add(new GridListControlProperties { Header = "No", Width = 50 }); gridListProperties.Add(new GridListControlProperties { Header = "Golongan", Width = 130 }); gridListProperties.Add(new GridListControlProperties { Header = "Kode Produk", Width = 110 }); gridListProperties.Add(new GridListControlProperties { Header = "Nama Produk", Width = 350 }); gridListProperties.Add(new GridListControlProperties { Header = "Satuan", Width = 50 }); gridListProperties.Add(new GridListControlProperties { Header = "Harga Beli", Width = 70 }); gridListProperties.Add(new GridListControlProperties { Header = "Harga Jual", Width = 70 }); gridListProperties.Add(new GridListControlProperties { Header = "Harga Jual", Width = 70 }); gridListProperties.Add(new GridListControlProperties { Header = "Harga Jual", Width = 70 }); gridListProperties.Add(new GridListControlProperties { Header = "Harga Jual", Width = 70 }); gridListProperties.Add(new GridListControlProperties { Header = "Diskon", Width = 50 }); gridListProperties.Add(new GridListControlProperties { Header = "Stok Etalase", Width = 60 }); gridListProperties.Add(new GridListControlProperties { Header = "Stok Gudang", Width = 60 }); gridListProperties.Add(new GridListControlProperties { Header = "Min. Stok Gudang", Width = 60 }); gridListProperties.Add(new GridListControlProperties { Header = "Status" }); GridListControlHelper.InitializeGridListControl <Produk>(this.gridList, _listOfProduk, gridListProperties, false, additionalRowCount: 1); this.gridList.Grid.Model.RowHeights[1] = 25; this.gridList.Grid.Model.Rows.FrozenCount = 1; this.gridList.Grid.PrepareViewStyleInfo += delegate(object sender, GridPrepareViewStyleInfoEventArgs e) { var subHeaderHargaJual = new string[] { "Retail", "Grosir 1", "Grosir 2", "Grosir 3" }; if (e.ColIndex > 6 && e.RowIndex == 1) { var colIndex = 7; foreach (var header in subHeaderHargaJual) { if (colIndex == e.ColIndex) { e.Style.Text = header; } colIndex++; } } }; if (_listOfProduk.Count > 0) { this.gridList.SetSelected(1, true); } // merge cell var column = 1; // kolom no this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); column = 2; // kolom golongan this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); column = 3; // kolom kode this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); column = 4; // kolom nama produk this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); column = 5; // kolom satuan this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); column = 6; // kolom harga beli this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); column = 7; // kolom harga jual this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 0, column + 3)); column = 11; // kolom diskon this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); column = 12; // kolom stok etalase this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); column = 13; // kolom stok gudang this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); column = 14; // kolom minimal stok this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); column = 15; // kolom status this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, column, 1, column)); var headerStyle = this.gridList.Grid.BaseStylesMap["Column Header"].StyleInfo; headerStyle.CellType = GridCellTypeName.Header; this.gridList.Grid.QueryCellInfo += delegate(object sender, GridQueryCellInfoEventArgs e) { if (e.RowIndex == 1) { if (e.ColIndex > 6) { e.Style.ModifyStyle(headerStyle, StyleModifyType.ApplyNew); } // we handled it, let the grid know e.Handled = true; } if (_listOfProduk.Count > 0) { if (e.RowIndex > 1) { var rowIndex = e.RowIndex - 2; if (rowIndex < _listOfProduk.Count) { var produk = _listOfProduk[rowIndex]; var listOfHargaGrosir = produk.list_of_harga_grosir; var hargaGrosir = 0d; switch (e.ColIndex) { case 1: var noUrut = (_pageNumber - 1) * _pageSize + e.RowIndex - 1; e.Style.CellValue = noUrut; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; break; case 2: if (produk.Golongan != null) { e.Style.CellValue = produk.Golongan.nama_golongan; } break; case 3: e.Style.CellValue = produk.kode_produk; break; case 4: e.Style.CellValue = produk.nama_produk; break; case 5: var satuan = string.Empty; if (produk.satuan.Length > 0) { satuan = produk.satuan; } e.Style.CellValue = satuan; break; case 6: e.Style.CellValue = NumberHelper.NumberToString(produk.harga_beli); e.Style.HorizontalAlignment = GridHorizontalAlignment.Right; break; case 7: // harga jual ritel e.Style.CellValue = NumberHelper.NumberToString(produk.harga_jual); e.Style.HorizontalAlignment = GridHorizontalAlignment.Right; break; case 8: // harga grosir 1 hargaGrosir = listOfHargaGrosir.Count > 0 ? listOfHargaGrosir[0].harga_grosir : 0; e.Style.CellValue = NumberHelper.NumberToString(hargaGrosir); e.Style.HorizontalAlignment = GridHorizontalAlignment.Right; break; case 9: // harga grosir 2 hargaGrosir = listOfHargaGrosir.Count > 1 ? listOfHargaGrosir[1].harga_grosir : 0; e.Style.CellValue = NumberHelper.NumberToString(hargaGrosir); e.Style.HorizontalAlignment = GridHorizontalAlignment.Right; break; case 10: // harga grosir 3 hargaGrosir = listOfHargaGrosir.Count > 2 ? listOfHargaGrosir[2].harga_grosir : 0; e.Style.CellValue = NumberHelper.NumberToString(hargaGrosir); e.Style.HorizontalAlignment = GridHorizontalAlignment.Right; break; case 11: e.Style.CellValue = produk.diskon; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; break; case 12: e.Style.CellValue = produk.stok; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; break; case 13: e.Style.CellValue = produk.stok_gudang; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; break; case 14: e.Style.CellValue = produk.minimal_stok_gudang; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; break; case 15: e.Style.CellValue = produk.is_aktif ? "Aktif" : "Non Aktif"; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; break; default: break; } // we handled it, let the grid know e.Handled = true; } } } }; }
private void InitializeGrid() { #region "Style declaration" //header Style this.gridControl1.DefaultRowHeight = (int)DpiAware.LogicalToDeviceUnits(22.0f); GridStyleInfo headerstyle = new GridStyleInfo(); headerstyle.Font.Size = 12; headerstyle.Font.Bold = true; headerstyle.VerticalAlignment = GridVerticalAlignment.Middle; headerstyle.HorizontalAlignment = GridHorizontalAlignment.Center; headerstyle.CellType = GridCellTypeName.Static; //Subheader Style GridStyleInfo subheaderstyle = new GridStyleInfo(); subheaderstyle.Font.Bold = true; subheaderstyle.VerticalAlignment = GridVerticalAlignment.Middle; subheaderstyle.HorizontalAlignment = GridHorizontalAlignment.Center; subheaderstyle.CellType = GridCellTypeName.Static; //Value Style GridStyleInfo valuestyle = new GridStyleInfo(); valuestyle.BackColor = SystemColors.Menu; valuestyle.TextColor = Color.Black; valuestyle.VerticalAlignment = GridVerticalAlignment.Middle; valuestyle.HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.FloatCellsMode = GridFloatCellsMode.BeforeDisplayCalculation; #endregion #region "Date Time Picker Cells" int rowIndex = 1, colIndex = 4; gridControl1.AllowProportionalColumnSizing = true; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Date Time Picker Cells"; rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex, 5)); this.gridControl1[rowIndex, colIndex - 1].Text = "Date Picker : (MM/dd/yyyy hh:mm)"; this.gridControl1[rowIndex, colIndex - 1].TextColor = Color.Black; colIndex++; colIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex, colIndex + 1)); this.gridControl1.CellModels.Add("DateTimePicker", new DateTimeCellModel(this.gridControl1.Model)); this.gridControl1[rowIndex, colIndex].CellType = "DateTimePicker"; this.gridControl1[rowIndex, colIndex].CellValueType = typeof(DateTime); this.gridControl1[rowIndex, colIndex].CellValue = DateTime.Now; this.gridControl1[rowIndex, colIndex].Format = "MM/dd/yyyy hh:mm"; rowIndex++; rowIndex++; colIndex -= 2; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex, 5)); this.gridControl1[rowIndex, colIndex - 1].Text = "Time Picker cell : (hh:mm:ss tt)"; this.gridControl1[rowIndex, colIndex - 1].TextColor = Color.Black; colIndex++; colIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex, colIndex + 1)); this.gridControl1[rowIndex, colIndex].CellType = "DateTimePicker"; this.gridControl1[rowIndex, colIndex].CellValueType = typeof(DateTime); this.gridControl1[rowIndex, colIndex].CellValue = DateTime.Now; this.gridControl1[rowIndex, colIndex].Format = "hh:mm:ss tt"; #endregion #region "DropDownGrid cells" GridControl GridA = new GridControl(); GridA.RowCount = 10; GridA.ColCount = 5; GridA.ThemesEnabled = true; GridA.CausesValidation = false; GridA[1, 1].Text = "Grid A"; GridA.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Office2007Blue; GridA.Properties.BackgroundColor = System.Drawing.Color.FromArgb(((System.Byte)(227)), ((System.Byte)(239)), ((System.Byte)(255))); GridA.Properties.GridLineColor = System.Drawing.Color.FromArgb(((System.Byte)(208)), ((System.Byte)(215)), ((System.Byte)(229))); GridA.DefaultGridBorderStyle = GridBorderStyle.Solid; GridA.ForeColor = System.Drawing.Color.MidnightBlue; GridA.Font = new System.Drawing.Font("Verdana", 8.5F); GridControl GridB = new GridControl(); GridB.RowCount = 6; GridB.ColCount = 6; GridB.CausesValidation = false; GridB.ThemesEnabled = true; GridB[1, 1].Text = "Grid B"; GridB.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro; DropDownGridCellModel aModel = new DropDownGridCellModel(this.gridControl1.Model); aModel.EmbeddedGrid = GridA; DropDownGridCellModel bModel = new DropDownGridCellModel(this.gridControl1.Model); bModel.EmbeddedGrid = GridB; gridControl1.CellModels.Add("GridADropCell", aModel); gridControl1.CellModels.Add("GridBDropCell", bModel); rowIndex += 3; colIndex -= 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "DropDown Grid Cells"; rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex, colIndex + 1)); this.gridControl1[rowIndex, colIndex].Text = "Grid A"; this.gridControl1[rowIndex, colIndex].CellType = "GridADropCell"; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex + 3, rowIndex, colIndex + 4)); this.gridControl1[rowIndex, colIndex + 3].Text = "Grid B"; this.gridControl1[rowIndex, colIndex + 3].CellType = "GridBDropCell"; #endregion #region "DropDown Form and User Control" rowIndex += 3; colIndex -= 2; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "DropDown Form and User Control"; rowIndex++; rowIndex++; this.gridControl1.CellModels.Add("DropDownForm", new DropDownFormCellModel(this.gridControl1.Model, new DropDownForm())); this.gridControl1.CellModels.Add("DropDownUserControl", new DropDownUserCellModel(this.gridControl1.Model, new DropDownUser())); ////DropDownForm... rowIndex++; colIndex = 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex, 4)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 5, rowIndex, 7)); gridControl1[rowIndex, colIndex].Text = "DropDownForm"; gridControl1[rowIndex, colIndex].TextColor = Color.Black; this.gridControl1[rowIndex, colIndex + 2].CellType = "DropDownForm"; this.gridControl1[rowIndex, colIndex + 2].Text = "choice1,choice3"; ////DropDownForm... rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex, 4)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 5, rowIndex, 7)); gridControl1[rowIndex, colIndex].Text = "DropDownUserControl"; gridControl1[rowIndex, colIndex].TextColor = Color.Black; this.gridControl1[rowIndex, colIndex + 2].CellType = "DropDownUserControl"; this.gridControl1[rowIndex, colIndex + 2].Text = "choice1,choice3"; #endregion #region "DropDOwnCalculator Cell" rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "DropDown Calculator TextBox"; rowIndex++; rowIndex++; #if HELPERCLASS RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.CalculatorTextBox); #else this.gridControl1.CellModels.Add("CalculatorTextBox", new DropDownCalculatorTextBoxCellModel(this.gridControl1.Model)); #endif rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 4, rowIndex, 6)); CalculatorControl c1 = new CalculatorControl(); c1.BorderStyle = Border3DStyle.Flat; c1.ButtonStyle = Syncfusion.Windows.Forms.ButtonAppearance.Office2007; c1.UseVisualStyle = true; GridStyleInfo style = gridControl1[rowIndex, 4]; style.CellType = "CalculatorTextBox"; style.Control = c1; style.Text = "Calculator TextBox"; this.gridControl1.Model.EnableGridListControlInComboBox = false; #endregion }
protected override void OnKeyDown(KeyEventArgs e) { bool runTests = false; if (runTests) { if (e.KeyData == Keys.T) { // Let's run some style tests. GridStyleInfo style = new GridStyleInfo(); MessageBox.Show(style.ToString("d"), "Empty Style"); MessageBox.Show(GridStyleInfo.Default.ToString(), "GridStyleInfo.Default.ToString()"); MessageBox.Show(Model.TableStyle.ToString(), "TableStyle.ToString()"); MessageBox.Show(Model.TableStyle.ToString("d"), "TableStyle.ToString(\"d\")"); MessageBox.Show(Model[1, 1].ToString(), "Model[1, 1].ToString()"); MessageBox.Show(Model[1, 1].ToString("d"), "Model[1, 1].ToString(\"d\")"); MessageBox.Show(Model.RowStyles[1].ToString(), "RowStyles[1].ToString()"); MessageBox.Show(Model.RowStyles[1].ToString("d"), "RowStyles[1].ToString(\"d\")"); string t = Model.TableStyle.ToString(); GridStyleInfo parseStyle = new GridStyleInfo(); parseStyle.ParseString(t); MessageBox.Show(parseStyle.ToString(), "parseStyle.ToString()"); } if (e.KeyData == Keys.F1) { // TODO: hangs when you change base style in property grid. StyleInfoForm form = new StyleInfoForm(Model.ColStyles[1]); form.ShowDialog(); Refresh(); } if (e.KeyData == Keys.F3) { CurrentCell.MoveTo(5, 4, GridSetCurrentCellOptions.SetFocus); return; } if (e.KeyData == Keys.F4) { // TODO: hangs when you change base style in property grid. StyleInfoForm form = new StyleInfoForm(Model[0, 0]); form.ShowDialog(); Refresh(); } if (e.KeyData == Keys.F5) { Model.Selections.Clear(); } if (e.KeyData == Keys.F6) { Model.Selections.Add(GridRangeInfo.Cells(2, 2, 10, 4)); } if (e.KeyData == Keys.M) { // TODO: Show Default value for base style in property grid GridBaseStyleCollectionEditor ce = new GridBaseStyleCollectionEditor(typeof(GridBaseStylesMap)); WindowsFormsEditorServiceContainer esc = new WindowsFormsEditorServiceContainer(null); PropertyDescriptor pd = TypeDescriptor.GetProperties(Model)["GridBaseStylesMap"]; TypeDescriptorContext tdc = new TypeDescriptorContext(Model, pd); tdc.ServiceProvider = esc; object v = ce.EditValue(tdc, esc, Model.BaseStylesMap.Clone()); if (esc.DialogResult == DialogResult.OK) { Model.BaseStylesMap = (GridBaseStylesMap)v; } } } base.OnKeyDown(e); }
public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); if (DpiAware.GetCurrentDpi() > 96) { this.CaptionBarHeight = (int)DpiAware.LogicalToDeviceUnits(this.CaptionBarHeight); } // // 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 = (int)DpiAware.LogicalToDeviceUnits(18.0f); this.gridControl1.DefaultColWidth = (int)DpiAware.LogicalToDeviceUnits(70.0f); this.gridControl1.DefaultGridBorderStyle = GridBorderStyle.Solid; this.gridControl1.Font = new System.Drawing.Font("Segoe UI", 8.5F); #endregion this.GridSettings(); }
/// <summary> /// Customizing Grid cells /// </summary> private void initializeGrid() { #region Style declaration this.gridControl1.DefaultRowHeight = (int)DpiAware.LogicalToDeviceUnits(18.0f); GridStyleInfo headerstyle = new GridStyleInfo(); headerstyle.Font.Size = 12; headerstyle.Font.Bold = true; headerstyle.TextColor = Color.Black; headerstyle.VerticalAlignment = GridVerticalAlignment.Middle; headerstyle.HorizontalAlignment = GridHorizontalAlignment.Center; headerstyle.CellType = GridCellTypeName.Static; GridStyleInfo subheaderstyle = new GridStyleInfo(); subheaderstyle.Font.Bold = true; subheaderstyle.VerticalAlignment = GridVerticalAlignment.Middle; subheaderstyle.HorizontalAlignment = GridHorizontalAlignment.Center; subheaderstyle.CellType = GridCellTypeName.Static; GridStyleInfo valuestyle = new GridStyleInfo(); valuestyle.BackColor = SystemColors.Menu; valuestyle.TextColor = Color.Black; valuestyle.VerticalAlignment = GridVerticalAlignment.Middle; valuestyle.HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.FloatCellsMode = GridFloatCellsMode.BeforeDisplayCalculation; int rowIndex = 1, colIndex = 2; #endregion #region Float Cells gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "FloatingCells"; rowIndex += 3; gridControl1[rowIndex, colIndex] = valuestyle; gridControl1[rowIndex, colIndex].Text = "Control Overview"; rowIndex++; gridControl1.Model.TextDataExchange.PasteTextFromBuffer( String.Concat( "Public Properties\r\n", "BackColor\tGets or sets the background color for the control. \r\n", "Controls\tGets the collection of controls contained within the control. \r\n", "Cursor\tGets or sets the cursor that is displayed when the mouse pointer is over the control. \r\n", "DefaultBackColor\tGets the default background color of the control. \r\n", "DefaultForeColor\tGets the default foreground color of the control. \r\n", "Dock\tGets or sets which edge of the parent container a control is docked to. \r\n", "Enabled\tGets or sets a value indicating whether the control can respond to user interaction. \r\n", "Font\tGets or sets the font of the text displayed by the control. \r\n", "ForeColor\tGets or sets the foreground color of the control. \r\n", ""), GridRangeInfo.Cell(rowIndex, colIndex), int.MaxValue); gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cells(1, 1, gridControl1.RowCount, gridControl1.ColCount)); #endregion #region CoveredCell rowIndex = 16; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Covered Cells"; rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 2, colIndex + 1)); gridControl1[rowIndex, colIndex].BackColor = Color.Orange; gridControl1[rowIndex, colIndex].Text = "Covered in rows & cols"; gridControl1[rowIndex, colIndex].TextColor = Color.Black; gridControl1[rowIndex, colIndex].Font.Bold = true; gridControl1[rowIndex, colIndex].VerticalAlignment = GridVerticalAlignment.Middle; gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex + 3, rowIndex, colIndex + 5)); gridControl1[rowIndex, colIndex + 3].BackColor = Color.Orange; gridControl1[rowIndex, colIndex + 3].Text = "Covered in cols"; gridControl1[rowIndex, colIndex + 3].TextColor = Color.Black; gridControl1[rowIndex, colIndex + 3].Font.Bold = true; gridControl1[rowIndex, colIndex + 3].VerticalAlignment = GridVerticalAlignment.Middle; gridControl1[rowIndex, colIndex + 3].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex + 7, rowIndex + 5, colIndex + 7)); gridControl1[rowIndex, colIndex + 7].BackColor = Color.Orange; gridControl1[rowIndex, colIndex + 7].Text = "Cov. in rows"; gridControl1[rowIndex, colIndex + 7].TextColor = Color.Black; gridControl1[rowIndex, colIndex + 7].Font.Bold = true; gridControl1[rowIndex, colIndex + 7].VerticalAlignment = GridVerticalAlignment.Middle; gridControl1[rowIndex, colIndex + 7].HorizontalAlignment = GridHorizontalAlignment.Center; #endregion #region Banner Cells rowIndex = 26; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Banner Cells"; rowIndex += 3; GridStyleInfo style; style = gridControl1[rowIndex, colIndex]; gridControl1.BanneredRanges.Add(GridRangeInfo.FromTlhw(rowIndex, colIndex, 8, colIndex + 1)); style.BackgroundImage = GetImage(@"cloud2.png"); style.Text = "cloud2.png"; style.TextColor = Color.Red; style.BackgroundImageMode = GridBackgroundImageMode.StretchImage; style = gridControl1[rowIndex, colIndex + 5]; gridControl1.BanneredRanges.Add(GridRangeInfo.FromTlhw(rowIndex, colIndex + 5, 8, colIndex + 1)); style.Interior = new BrushInfo(GradientStyle.PathEllipse, SystemColors.Highlight, Color.White); style.Text = "GradientStyle.PathEllipse"; style.TextColor = Color.Blue; #endregion #region Custom Borders rowIndex = 39; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Custom Borders Cells"; gridControl1.DrawCellFrameAppearance += new GridDrawCellBackgroundEventHandler(gridControl1_DrawCellFrameAppearance); gridControl1.BeginUpdate(); rowIndex += 3; rindex = rowIndex; cindex = colIndex; for (int i = rowIndex; i <= rindex + 5; i++) { for (int j = colIndex; j <= cindex + 7; j++) { GridStyleInfo newstyle = gridControl1[i, j]; newstyle.BorderMargins = new GridMarginsInfo(5, 5, 5, 5); newstyle.Borders.All = GridBorder.Empty; newstyle.CellAppearance = GridCellAppearance.Flat; } } gridControl1.EndUpdate(true); #endregion #region CustomDraw gridControl1.ActivateCurrentCellBehavior = GridCellActivateAction.DblClickOnCell; rowIndex = 49; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Custom Drawing in GridCells"; //creating the datatable for the datasource DataTable dt = new DataTable(); dt.Columns.Add("BookID"); dt.Columns.Add("BookName"); dt.Columns.Add("Author"); dt.Columns.Add("Price"); dt.Rows.Add(new object[] { "BookID", "BookName", "Author", "Price" }); dt.Rows.Add(new object[] { "1001", "Computer Networks", "Tanenbaum", "75.00" }); dt.Rows.Add(new object[] { "1002", "DBMS", "Navbathe", "85.00" }); dt.Rows.Add(new object[] { "1003", "Let us C", "Leland Beck", "50.00" }); dt.Rows.Add(new object[] { "1004", "System Software", "Hamacher", "78.00" }); dt.Rows.Add(new object[] { "1005", "Computer Organization", "Carl", "50.00" }); dt.Rows.Add(new object[] { "1006", "Test your c skills", "Ivan", "75.00" }); dt.Rows.Add(new object[] { "1007", "C#.Net", "Alexis", "50.00" }); dt.Rows.Add(new object[] { "1008", "Multimedia", "Leon", "75.00" }); dt.AcceptChanges(); rowIndex += 3; gridControl1[rowIndex, 6].Text = "Cart"; gridControl1[rowIndex, 7].Text = "BookStatus"; for (int i = rowIndex + 1; i <= 60; i++) { this.gridControl1[i, 6].CellValue = 0; } gridControl1.PopulateValues(GridRangeInfo.Cells(52, 2, 60, 5), dt); for (int k = 53; k <= 60; k++) { for (int l = 2; l <= 7; l++) { //set the background of the cell gridControl1[k, l].Interior = new BrushInfo(GradientStyle.ForwardDiagonal, Color.FromArgb(255, 187, 111), Color.White); } } for (int l = 2; l <= 7; l++) { //set the celltype as header gridControl1[52, l].CellType = GridCellTypeName.Header; } this.gridControl1.CellClick += new GridCellClickEventHandler(HandleAClick); //Handle the following events to do custom painting this.gridControl1.CellDrawn += new GridDrawCellEventHandler(gridControl1_CellDrawn); this.gridControl1.DrawCell += new GridDrawCellEventHandler(gridControl1_DrawCell); #endregion }
/// <summary> /// Setting GridGrouping control Properties /// </summary> private void GridSettings() { #region Buffer Text gridControl1.Model.TextDataExchange.PasteTextFromBuffer( "1\tDavolio Nancy\r\n" + "2\tFuller Andrew\r\n"+ "3\tLeverling Janet\r\n"+ "4\tPeacock Margaret\r\n" + "5\tBuchanan Steven\r\n"+ "6\tSuyama Michael\r\n"+ "7\tKing Robert\r\n"+ "8\tCallahan Laura\r\n"+ "9\tDodsworth Anne\r\n", GridRangeInfo.Cell(1, 1), int.MaxValue); #endregion #region GridStyleInfo GridStyleInfo style; style = new GridStyleInfo(); style.Interior = new BrushInfo(Color.FromArgb(0xED, 0xF0, 0xF7)); style.TextColor = Color.FromArgb(238, 122, 3); //Color.Orange; gridControl1.ChangeCells(GridRangeInfo.Cells(1, 1, 9, 3), style); style = new GridStyleInfo(); style.HorizontalAlignment = GridHorizontalAlignment.Right; style.CellValueType = typeof(int); style.Format = "000"; gridControl1.ChangeCells(GridRangeInfo.Cells(1, 1, 9, 1), style); #endregion gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cells(1, 1, 9, 3)); gridControl1.CommandStack.Enabled = true; gridControl2.CommandStack.Enabled = true; gridControl1.AllowDrop = true; gridControl2.AllowDrop = true; gridControl1.ShowMessageBoxOnDrop = false; gridControl2.ShowMessageBoxOnDrop = false; // // TODO: Add any constructor code after InitializeComponent call // richTextBox1.Text = "Drag content using OLE Drag-and-Drop between grids, any other application or use Copy Paste \r\n" + "Sample Data:\r\n" + "1 Davolio Nancy\r\n"+ "2 Fuller Andrew\r\n"+ "3 Leverling Janet\r\n"+ "4 Peacock Margaret\r\n"+ "5 Buchanan Steven\r\n"+ "6 Suyama Michael\r\n"+ "7 King Robert\r\n"+ "8 Callahan Laura\r\n"+ "9 Dodsworth Anne\r\n"; this.gridControl1.DefaultRowHeight = 22; this.gridControl1.DefaultColWidth = 70; this.gridControl1.GridVisualStyles = GridVisualStyles.Metro; this.gridControl1.DefaultGridBorderStyle = GridBorderStyle.Solid; this.gridControl1.Properties.GridLineColor = Color.FromArgb(208, 215, 229); style = gridControl1.BaseStylesMap["Header"].StyleInfo; style.Font.Facename = "Segoe UI"; this.gridControl2.DefaultRowHeight = 22; this.gridControl2.DefaultColWidth = 70; this.gridControl2.GridVisualStyles = GridVisualStyles.Metro; this.gridControl2.DefaultGridBorderStyle = GridBorderStyle.Solid; this.gridControl2.Properties.GridLineColor = Color.FromArgb(208, 215, 229); style = gridControl2.BaseStylesMap["Header"].StyleInfo; style.Font.Facename = "Segoe UI"; this.BackColor = Color.White;// FromArgb(223, 227, 239); this.StartPosition = FormStartPosition.CenterScreen; //tab key navigation set as false to move the next control this.gridControl1.WantTabKey = false; this.gridControl2.WantTabKey = false; }
private void SetUpDisplaySheet() { int row = 2; int col = 1; //some general settings this.gridDisplay.ColWidths[col] = 220; this.gridDisplay.TableStyle.Enabled = false; this.gridDisplay.TableStyle.Font.Facename = "Arial"; this.gridDisplay.EnterKeyBehavior = GridDirectionType.Down; #region inputs //main title this.gridDisplay.CoveredRanges.Add(GridRangeInfo.Cells(row, col, row, col + 4)); GridStyleInfo style = this.gridDisplay[row, col]; style.Text = "Retirement Calculator"; style.Font.Size = 14f; style.Font.Bold = true; style.HorizontalAlignment = GridHorizontalAlignment.Center; this.gridDisplay.RowHeights[row] = 25; //inputs row += 1; this.gridDisplay.RowHeights[row] = 10; row += 1; //this.gridDisplay.CoveredRanges.Add(GridRangeInfo.Cells(row, col, row, col + 1)); style = this.gridDisplay[row, col]; style.Text = "Inputs"; style.Font.Size = 10f; //style.Font.Bold = true; style.Font.Underline = true; style.HorizontalAlignment = GridHorizontalAlignment.Right; //results //this.gridDisplay.CoveredRanges.Add(GridRangeInfo.Cells(row, col + 3, row, col + 4)); style = this.gridDisplay[row, col + 2]; style.Text = "Results"; style.Font.Size = 10f; //style.Font.Bold = true; style.Font.Underline = true; style.HorizontalAlignment = GridHorizontalAlignment.Right; //Initial Year row += 1; this.gridDisplay.RowHeights[row] = 5; row += 1; style = this.gridDisplay[row, col]; style.Text = "Initial Year:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.Text = "2004"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //Initial Age spouse1 row += 1; style = this.gridDisplay[row, col]; style.Text = "Initial Age spouse1:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.Text = "56"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //Initial Age spouse2 row += 1; style = this.gridDisplay[row, col]; style.Text = "Initial Age spouse2:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.Text = "46"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //Initial savings balance row += 1; style = this.gridDisplay[row, col]; style.Text = "Initial savings balance:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.CellValueType = typeof(double); style.Text = "400000"; style.Format = "#,##0.00"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //return percentage1 row += 1; style = this.gridDisplay[row, col]; style.Text = "return percentage1:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.CellValueType = typeof(double); style.Text = "8"; style.Format = "#,##0.00"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //return volatility1 row += 1; style = this.gridDisplay[row, col]; style.Text = "return volatility1:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.CellValueType = typeof(double); style.Text = "10"; style.Format = "#,##0.00"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //return percentage2 row += 1; style = this.gridDisplay[row, col]; style.Text = "return percentage2:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.CellValueType = typeof(double); style.Text = "4"; style.Format = "#,##0.00"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //return volatility2 row += 1; style = this.gridDisplay[row, col]; style.Text = "return volatility2:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.CellValueType = typeof(double); style.Text = "3"; style.Format = "#,##0.00"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //income COLA row += 1; style = this.gridDisplay[row, col]; style.Text = "income COLA:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.CellValueType = typeof(double); style.Text = "3"; style.Format = "#,##0.00"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //expense COLA row += 1; style = this.gridDisplay[row, col]; style.Text = "expense COLA:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.CellValueType = typeof(double); style.Text = "3"; style.Format = "#,##0.00"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //SS age spouse1 row += 1; style = this.gridDisplay[row, col]; style.Text = "SS age spouse1:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.Text = "63"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //SS age spouse2 row += 1; style = this.gridDisplay[row, col]; style.Text = "SS age spouse2:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.Text = "63"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //SS initial amount (per month) spouse1 row += 1; style = this.gridDisplay[row, col]; style.Text = "SS initial amount (per month) spouse1:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.CellValueType = typeof(double); style.Text = "1300"; style.Format = "#,##0.00"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //SS initial amount (% of spouse1) spouse2 row += 1; style = this.gridDisplay[row, col]; style.Text = "SS initial amount (% of spouse1) spouse2:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.CellValueType = typeof(double); style.Text = "75"; style.Format = "#,##0.00"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //SS spouse1 dies row += 1; style = this.gridDisplay[row, col]; style.Text = "spouse1 dies:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.Text = "71"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //SS spouse1 retires row += 1; style = this.gridDisplay[row, col]; style.Text = "spouse1 retires:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.Text = "60"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //Initial Annual Draw row += 1; style = this.gridDisplay[row, col]; style.Text = "initial Annual Draw:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.CellValueType = typeof(double); style.Text = "50000"; style.Format = "#,##0.00"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; //Random Behavior row += 1; style = this.gridDisplay[row, col]; style.Text = "random behavior:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.CellValueType = typeof(int); style.CellValue = 1; style.Format = "0"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; #endregion //set up results //Initial Year row = 6; col = 3; this.gridDisplay.ColWidths[col] = 120; style = this.gridDisplay[row, col]; style.Text = "Go Broke year:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.Text = "=Calc!A2"; style.CellType = "FormulaCell"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; row += 1; style = this.gridDisplay[row, col]; style.Text = "Spouse1 Age:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.Text = "=Calc!A3"; style.CellType = "FormulaCell"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; row += 1; style = this.gridDisplay[row, col]; style.Text = "Spouse2 Age:"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.Text = "=Calc!A4"; style.CellType = "FormulaCell"; style.Font.Bold = true; style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; row += 3; this.gridDisplay.CoveredRanges.Add(GridRangeInfo.Cells(row, col, row, col + 1)); style = this.gridDisplay[row, col]; style.Enabled = true; style.BorderMargins.Left = 30; style.BorderMargins.Right = 20; style.CellType = "PushButton"; style.Description = "Probabilities"; this.gridDisplay.PushButtonClick += new GridCellPushButtonClickEventHandler(gridDisplay_PushButtonClick); row += 1; row10 = row; style = this.gridDisplay[row, col]; style.Text = ">= 10 years:"; style.Enabled = false; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.Text = ""; style.Font.Bold = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; row += 1; style = this.gridDisplay[row, col]; style.Text = ">= 20 years:"; style.Enabled = false; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.Text = ""; style.Font.Bold = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; row += 1; style = this.gridDisplay[row, col]; style.Text = ">= 30 years:"; style.Enabled = false; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.Text = ""; style.Font.Bold = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; row += 1; style = this.gridDisplay[row, col]; style.Text = ">= 40 years:"; style.Enabled = false; style.HorizontalAlignment = GridHorizontalAlignment.Right; style = this.gridDisplay[row, col + 1]; style.Text = ""; style.Font.Bold = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; style = this.gridDisplay[row, col + 1]; style.Text = ""; style.CellType = "FormulaCell"; style.Font.Bold = true; // style.Enabled = true; style.HorizontalAlignment = GridHorizontalAlignment.Left; }
private void Form1_Load(object sender, System.EventArgs e) { this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, 30, 12), GetTable()); }
private void InitializeGrid() { #region "Style declaration" //headerstyle this.gridControl1.DefaultRowHeight = 22; GridStyleInfo headerstyle = new GridStyleInfo(); headerstyle.Font.Size = 12; headerstyle.Font.Bold = true; headerstyle.TextColor = Color.Black; headerstyle.VerticalAlignment = GridVerticalAlignment.Middle; headerstyle.HorizontalAlignment = GridHorizontalAlignment.Center; headerstyle.CellType = GridCellTypeName.Static; //subheaderstyle GridStyleInfo subheaderstyle = new GridStyleInfo(); subheaderstyle.Font.Bold = true; subheaderstyle.VerticalAlignment = GridVerticalAlignment.Middle; subheaderstyle.HorizontalAlignment = GridHorizontalAlignment.Center; subheaderstyle.CellType = GridCellTypeName.Static; GridStyleInfo valuestyle = new GridStyleInfo(); valuestyle.BackColor = SystemColors.Menu; valuestyle.TextColor = Color.Black; valuestyle.VerticalAlignment = GridVerticalAlignment.Middle; valuestyle.HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.FloatCellsMode = GridFloatCellsMode.BeforeDisplayCalculation; int rowIndex = 1, colIndex = 2; #endregion #region "Chart in Cell" this.InitializeData(); this.gridControl1.CellModels.Add("ChartCell", new GridChartCellModel(this.gridControl1.Model)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "ChartControl in GridCells"; #region "ChartData" this.gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(4, 4, 4, 8)); style = this.gridControl1[4, 4]; style.Text = "Chart Data"; style.Font.Bold = true; style.Font.Facename = "Times New Roman"; style.Font.Size = 12.75F; style.HorizontalAlignment = GridHorizontalAlignment.Center; this.gridControl1.RowHeights[4] = 21; GridRangeStyle rstyle = new GridRangeStyle(); rstyle.Range = GridRangeInfo.Cell(5, 4); rstyle.StyleInfo.BaseStyle = "Header"; rstyle.StyleInfo.CellType = "Header"; rstyle.StyleInfo.Font.Bold = true; rstyle.StyleInfo.Font.Facename = "Verdana"; rstyle.StyleInfo.Themed = true; this.gridControl1.RangeStyles.Add(rstyle); GridRangeStyle rstyle2 = new GridRangeStyle(); rstyle2.Range = GridRangeInfo.Cells(5, 5, 5, 8); rstyle2.StyleInfo.BaseStyle = "Column Header"; rstyle2.StyleInfo.CellType = "Header"; rstyle2.StyleInfo.Font.Bold = true; rstyle2.StyleInfo.Font.Facename = "Verdana"; rstyle2.StyleInfo.Themed = true; this.gridControl1.RangeStyles.Add(rstyle2); this.gridControl1[5, 5].Text = "Team1"; this.gridControl1[5, 6].Text = "Team2"; this.gridControl1[5, 7].Text = "Team3"; this.gridControl1[5, 8].Text = "Team4"; GridRangeStyle rstyle3 = new GridRangeStyle(); rstyle3.Range = GridRangeInfo.Cells(6, 4, 8, 4); rstyle3.StyleInfo.BaseStyle = "Row Header"; rstyle3.StyleInfo.CellType = "Header"; rstyle3.StyleInfo.Font.Bold = true; rstyle3.StyleInfo.Font.Facename = "Verdana"; rstyle3.StyleInfo.Themed = true; this.gridControl1.RangeStyles.Add(rstyle3); this.gridControl1[6, 4].Text = "Data1"; this.gridControl1[7, 4].Text = "Data2"; this.gridControl1[8, 4].Text = "Data3"; #endregion #region "ChartControl" //Define the Range where the chart should be displayed (8,2,26,8) 27, 2, 28, 8)); this.gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(10, 4, 28, 10)); this.gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(29, 4, 30, 10)); style = this.gridControl1[29, 4]; style.Text = "Interactive Chart Cell - Try Changing the ChartData"; style.Font.Size = 12; style.Font.Bold = true; style.Font.Facename = "Arial"; style.HorizontalAlignment = GridHorizontalAlignment.Center; style = this.gridControl1[10, 4]; style.CellType = "ChartCell"; csp = new ChartStyleProperties(style); csp.ChartType = ChartSeriesType.Column; csp.TitleText = "Chart Cell"; csp.Series3D = false; csp.TitleAlignment = StringAlignment.Center; cm = (GridChartCellModel)this.gridControl1.CellModels["ChartCell"]; ////Pass the CellValueRange and ChartAreaRange to cell model. cm.CellValueRangeInfo = GridRangeInfo.Cells(6, 5, 8, 8); cm.ChartAreaRangeInfo = GridRangeInfo.Cells(8, 2, 26, 9); #endregion #endregion #region "Grid in Cell" rowIndex = 32; colIndex = 4; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "GridInCells"; rowIndex += 3; #if HELPERCLASS RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.GridinCell); #else gridControl1.CellModels.Add("GridinCell", new GridInCellModel(gridControl1.Model)); #endif GridControl grid; this.gridControl1[rowIndex, colIndex].CellType = "GridinCell"; this.gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 4, 10)); grid = new ContentCellDemo.CellEmbeddedGrid(this.gridControl1); grid.RowCount = 20; grid.ColCount = 20; grid[1, 1].Text = "this is a 20x20 grid"; grid.ThemesEnabled = true; grid.Office2007ScrollBars = true; this.gridControl1[rowIndex, colIndex].Control = grid; this.gridControl1.Controls.Add(grid); this.gridControl1.DefaultRowHeight = 18; this.gridControl1.DefaultColWidth = 75; grid.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Office2007Blue; this.gridControl1.Model.Options.DisplayEmptyColumns = true; #endregion #region "XHTML Cell" rowIndex = 42; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "XHTML Cells"; rowIndex += 3; RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.XhtmlCell); string xhtml1 = "<body style=\"font-family:Arial; line-height:1em\"> "; xhtml1 += "<h1 style=\"text-align:center; color:#EE7A03 \">XhtmlCells</h1>"; //#008888 xhtml1 += "<p/>"; xhtml1 += "<p>XhtmlCells use the RichTextBoxSupportsXHTML control from GotDotNet user samples to display XHTML formatted text inside a cell.</p>"; xhtml1 += "</body>"; gridControl1[rowIndex, colIndex].CellType = "XhtmlCell"; gridControl1[rowIndex, colIndex].Text = xhtml1; gridControl1.RowHeights[rowIndex] = 50; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 10, colIndex + 6)); rowIndex += 10; rowIndex++; rowIndex++; #endregion #region "Calendar Cells" RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.Calendar); rowIndex = 57; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Calendar Cells"; rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 4, rowIndex + 8, 6)); style = gridControl1[rowIndex, 4]; style.CellType = "Calendar"; style.Control = new MonthCalendar(); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 8, rowIndex + 8, 10)); style = gridControl1[rowIndex, 8]; style.CellType = "Calendar"; style.Control = new MonthCalendar(); #endregion #region "PictureBoxCells" rowIndex = 71; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "PictureBox Cells"; rowIndex += 3; RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.PictureBox); Syncfusion.GridHelperClasses.PictureBoxStyleProperties tsp = new Syncfusion.GridHelperClasses.PictureBoxStyleProperties(new GridStyleInfo(gridControl1.TableStyle)); tsp.SizeMode = PictureBoxSizeMode.StretchImage; Syncfusion.GridHelperClasses.PictureBoxStyleProperties sp; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 4, rowIndex + 6, 6)); style = gridControl1[rowIndex, 4]; style.CellType = "PictureBox"; sp = new Syncfusion.GridHelperClasses.PictureBoxStyleProperties(style); sp.Image = GetImage("car1.jpg"); sp.SizeMode = PictureBoxSizeMode.StretchImage; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 8, rowIndex + 6, 10)); style = gridControl1[rowIndex, 8]; style.CellType = "PictureBox"; sp = new Syncfusion.GridHelperClasses.PictureBoxStyleProperties(style); sp.Image = GetImage("car2.jpg"); sp.SizeMode = PictureBoxSizeMode.StretchImage; #endregion this.gridControl1.CurrentCellEditingComplete += new EventHandler(gridControl1_CurrentCellEditingComplete); }
private void InitializeGrid() { #region "Style declaration" GridStyleInfo headerstyle = new GridStyleInfo(); headerstyle.Font.Size = 12; headerstyle.Font.Bold = true; headerstyle.VerticalAlignment = GridVerticalAlignment.Middle; headerstyle.HorizontalAlignment = GridHorizontalAlignment.Center; headerstyle.CellType = GridCellTypeName.Static; GridStyleInfo subheaderstyle = new GridStyleInfo(); subheaderstyle.Font.Bold = true; subheaderstyle.VerticalAlignment = GridVerticalAlignment.Middle; subheaderstyle.HorizontalAlignment = GridHorizontalAlignment.Center; subheaderstyle.CellType = GridCellTypeName.Static; GridStyleInfo valuestyle = new GridStyleInfo(); valuestyle.BackColor = SystemColors.Menu; valuestyle.TextColor = Color.Black; valuestyle.VerticalAlignment = GridVerticalAlignment.Middle; valuestyle.HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.TableStyle.FloatCell = true; gridControl1.FloatCellsMode = GridFloatCellsMode.BeforeDisplayCalculation; gridControl1.DefaultRowHeight = (int)DpiAware.LogicalToDeviceUnits(22.0f); #endregion gridControl1.BeginUpdate(); int rowIndex = 1, colIndex = 4; #region "IntegerTextBox" gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Integer TextBox Cell"; rowIndex += 3; RegisterCellModel.GridCellType(this.gridControl1, CustomCellTypes.IntegerTextBox); this.gridControl1[rowIndex, colIndex - 2].Text = ".CellType = CustomCellTypes.IntegerTextBox"; this.gridControl1[rowIndex, colIndex - 2].HorizontalAlignment = GridHorizontalAlignment.Center; this.gridControl1[rowIndex, colIndex + 2] = valuestyle; this.gridControl1[rowIndex, colIndex + 2].CellType = CustomCellTypes.IntegerTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 2].CellValue = 56789; this.gridControl1[rowIndex, colIndex + 3] = valuestyle; this.gridControl1[rowIndex, colIndex + 3].CellType = CustomCellTypes.IntegerTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 3].CellValue = 34210; rowIndex++; this.gridControl1[rowIndex, colIndex + 2] = valuestyle; this.gridControl1[rowIndex, colIndex + 2].CellType = CustomCellTypes.IntegerTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 2].CellValue = 1234; this.gridControl1[rowIndex, colIndex + 3] = valuestyle; this.gridControl1[rowIndex, colIndex + 3].CellType = CustomCellTypes.IntegerTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 3].CellValue = 54321; #endregion #region "DoubleTextBox" rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Double TextBox Cell"; rowIndex += 3; RegisterCellModel.GridCellType(this.gridControl1, CustomCellTypes.DoubleTextBox); this.gridControl1[rowIndex, colIndex - 2].Text = ".CellType = CustomCellTypes.DoubleTextBox"; this.gridControl1[rowIndex, colIndex - 2].HorizontalAlignment = GridHorizontalAlignment.Center; this.gridControl1[rowIndex, colIndex + 2] = valuestyle; this.gridControl1[rowIndex, colIndex + 2].CellType = CustomCellTypes.DoubleTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 2].CellValue = 123456; this.gridControl1[rowIndex, colIndex + 3] = valuestyle; this.gridControl1[rowIndex, colIndex + 3].CellType = CustomCellTypes.DoubleTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 3].CellValue = 876543; rowIndex++; this.gridControl1[rowIndex, colIndex + 2] = valuestyle; this.gridControl1[rowIndex, colIndex + 2].CellType = CustomCellTypes.DoubleTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 2].CellValue = 13579; this.gridControl1[rowIndex, colIndex + 3] = valuestyle; this.gridControl1[rowIndex, colIndex + 3].CellType = CustomCellTypes.DoubleTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 3].CellValue = 975324; #endregion #region "Percentage TextBox" rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Percentage TextBox Cell"; rowIndex += 3; RegisterCellModel.GridCellType(this.gridControl1, CustomCellTypes.PercentTextBox); this.gridControl1[rowIndex, colIndex - 2].Text = ".CellType = CustomCellTypes.DoubleTextBox"; this.gridControl1[rowIndex, colIndex - 2].HorizontalAlignment = GridHorizontalAlignment.Center; this.gridControl1[rowIndex, colIndex + 2] = valuestyle; this.gridControl1[rowIndex, colIndex + 2].CellType = CustomCellTypes.PercentTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 2].CellValue = 54; this.gridControl1[rowIndex, colIndex + 3] = valuestyle; this.gridControl1[rowIndex, colIndex + 3].CellType = CustomCellTypes.PercentTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 3].CellValue = 65; rowIndex++; this.gridControl1[rowIndex, colIndex + 2] = valuestyle; this.gridControl1[rowIndex, colIndex + 2].CellType = CustomCellTypes.PercentTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 2].CellValue = 84; this.gridControl1[rowIndex, colIndex + 3] = valuestyle; this.gridControl1[rowIndex, colIndex + 3].CellType = CustomCellTypes.PercentTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 3].CellValue = 92; #endregion #region "EnhancedNumericUpdown" rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Enhanced Numeric Up-Down Cell"; RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.FNumericUpDown); rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "Allow Decimal Increment and Decrement(step by 0.2,0.01,0.001)"; #region #1 rowIndex++; rowIndex++; gridControl1.Model.RowHeights[rowIndex] = (int)DpiAware.LogicalToDeviceUnits(20.0f); GridStyleInfo style = gridControl1[rowIndex, colIndex - 1]; style.CellType = "FNumericUpDown"; style.Text = "0.5"; FloatNumericUpDownStyleProperties sp = new FloatNumericUpDownStyleProperties(style); sp.StyleInfo.BackColor = SystemColors.Window; sp.FloatNumericUpDownProperties.Maximum = 15.0; sp.FloatNumericUpDownProperties.Minimum = 0.0; sp.FloatNumericUpDownProperties.StartValue = 0.5; sp.FloatNumericUpDownProperties.Step = 0.2; sp.FloatNumericUpDownProperties.WrapValue = true; sp.FloatNumericUpDownProperties.DecimalPlaces = 1; style = gridControl1[rowIndex, colIndex + 1]; style.CellType = "FNumericUpDown"; style.Text = "10.10"; sp = new FloatNumericUpDownStyleProperties(style); sp.StyleInfo.BackColor = SystemColors.Window; sp.FloatNumericUpDownProperties.Maximum = 12.50; sp.FloatNumericUpDownProperties.Minimum = 0.0; sp.FloatNumericUpDownProperties.StartValue = 10.10; sp.FloatNumericUpDownProperties.Step = 0.01; sp.FloatNumericUpDownProperties.WrapValue = true; sp.FloatNumericUpDownProperties.DecimalPlaces = 2; style = gridControl1[rowIndex, colIndex + 3]; style.CellType = "FNumericUpDown"; style.Text = "15.000"; sp = new FloatNumericUpDownStyleProperties(style); sp.StyleInfo.BackColor = SystemColors.Window; sp.FloatNumericUpDownProperties.Maximum = 15.225; sp.FloatNumericUpDownProperties.Minimum = 0.0; sp.FloatNumericUpDownProperties.StartValue = 15.000; sp.FloatNumericUpDownProperties.Step = 0.001; sp.FloatNumericUpDownProperties.WrapValue = true; sp.FloatNumericUpDownProperties.DecimalPlaces = 3; sp.FloatNumericUpDownProperties.Orientation = FloatNumericUpDownProperties.OrientationType.Vertical; sp.FloatNumericUpDownProperties.InterceptArrowkeys = false; sp.FloatNumericUpDownProperties.ThousandsSeparator = false; #endregion #region #2 rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "Option to decrease number beyond Zero(Negative numbers allowed)"; rowIndex++; rowIndex++; gridControl1.Model.RowHeights[rowIndex] = (int)DpiAware.LogicalToDeviceUnits(20.0f); style = this.gridControl1[rowIndex, colIndex - 1]; style.CellType = "FNumericUpDown"; style.Text = "-4"; sp = new FloatNumericUpDownStyleProperties(style); #endregion #region #3 rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "Use Up/Down arrow keys from Keyboard to increment/decrement the numeric value"; rowIndex++; rowIndex++; gridControl1.Model.RowHeights[rowIndex] = (int)DpiAware.LogicalToDeviceUnits(20.0f); style = this.gridControl1[rowIndex, colIndex - 1]; style.CellType = "FNumericUpDown"; style.Text = "100000"; sp = new FloatNumericUpDownStyleProperties(style); sp.StyleInfo.BackColor = SystemColors.Window; sp.FloatNumericUpDownProperties.Maximum = 10000000000; sp.FloatNumericUpDownProperties.Minimum = 1; sp.FloatNumericUpDownProperties.StartValue = 100000; sp.FloatNumericUpDownProperties.Step = 100; sp.FloatNumericUpDownProperties.WrapValue = true; sp.FloatNumericUpDownProperties.DecimalPlaces = 0; sp.FloatNumericUpDownProperties.Orientation = FloatNumericUpDownProperties.OrientationType.Vertical; sp.FloatNumericUpDownProperties.InterceptArrowkeys = true; sp.FloatNumericUpDownProperties.ThousandsSeparator = false; #endregion #region #4 rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "Setting the Orientation property"; rowIndex++; rowIndex++; gridControl1.Model.RowHeights[rowIndex] = (int)DpiAware.LogicalToDeviceUnits(20.0f); style = this.gridControl1[rowIndex, colIndex - 1]; style.CellType = "FNumericUpDown"; style.Text = "5.5"; sp = new FloatNumericUpDownStyleProperties(style); sp.StyleInfo.BackColor = SystemColors.Window; sp.FloatNumericUpDownProperties.Maximum = 15.5; sp.FloatNumericUpDownProperties.Minimum = 0.5; sp.FloatNumericUpDownProperties.StartValue = .5; sp.FloatNumericUpDownProperties.Step = .5; sp.FloatNumericUpDownProperties.WrapValue = true; sp.FloatNumericUpDownProperties.DecimalPlaces = 1; sp.FloatNumericUpDownProperties.Orientation = FloatNumericUpDownProperties.OrientationType.Horizontal; sp.FloatNumericUpDownProperties.InterceptArrowkeys = true; sp.FloatNumericUpDownProperties.ThousandsSeparator = false; style = this.gridControl1[rowIndex, colIndex + 1]; style.CellType = "FNumericUpDown"; style.Text = "10.0"; sp = new FloatNumericUpDownStyleProperties(style); sp.StyleInfo.BackColor = SystemColors.Window; sp.FloatNumericUpDownProperties.Maximum = 15.5; sp.FloatNumericUpDownProperties.Minimum = 0.5; sp.FloatNumericUpDownProperties.Step = .5; sp.FloatNumericUpDownProperties.DecimalPlaces = 1; sp.FloatNumericUpDownProperties.Orientation = FloatNumericUpDownProperties.OrientationType.Vertical; #endregion #endregion this.gridControl1.Model.Options.DisplayEmptyColumns = true; gridControl1.EndUpdate(true); gridControl1.Refresh(); }
private void InitializeGrid() { #region Style prerequistes GridStyleInfo standard = gridControl1.BaseStylesMap["Standard"].StyleInfo; standard.Font.Bold = false; standard.Font.Facename = "Verdana"; //"Verdana"; standard.Font.Size = 10; standard.TextColor = Color.FromArgb(240, 0, 21, 84); gridControl1.Font = new System.Drawing.Font("Verdana", 8.5F); // grab some images... ImageList imageList = new ImageList(); imageList.Images.Add(SystemIcons.Warning.ToBitmap()); imageList.Images.Add(SystemIcons.Application.ToBitmap()); imageList.Images.Add(SystemIcons.Asterisk.ToBitmap()); imageList.Images.Add(SystemIcons.Error.ToBitmap()); imageList.Images.Add(SystemIcons.Exclamation.ToBitmap()); imageList.Images.Add(SystemIcons.Hand.ToBitmap()); imageList.Images.Add(SystemIcons.Information.ToBitmap()); imageList.Images.Add(SystemIcons.Question.ToBitmap()); //standard.ImageList = imageList; Icon icon = new Icon(GetType().Module.Assembly.GetManifestResourceStream("ContentCellDemo.gridform.ico")); imageList.Images.Add(icon.ToBitmap()); icon = new Icon(GetType().Module.Assembly.GetManifestResourceStream("ContentCellDemo.toolsform.ico")); imageList.Images.Add(icon.ToBitmap()); //imageList.Images.Add(Image.FromFile(@"..\..\Resources\Car1.jpg")); //imageList.Images.Add(Image.FromFile(@"..\..\Resources\car2.jpg")); //imageList.Images.Add(Image.FromFile(@"..\..\Resources\camera.ico")); #endregion #region Codes to apply celltypes in Grid this.gridControl1.BeginUpdate(); #region Style declaration GridStyleInfo headerstyle = new GridStyleInfo(); headerstyle.Font.Size = 12; headerstyle.Font.Bold = true; headerstyle.VerticalAlignment = GridVerticalAlignment.Middle; headerstyle.HorizontalAlignment = GridHorizontalAlignment.Center; headerstyle.CellType = GridCellTypeName.Static; GridStyleInfo subheaderstyle = new GridStyleInfo(); subheaderstyle.Font.Bold = true; subheaderstyle.VerticalAlignment = GridVerticalAlignment.Middle; subheaderstyle.HorizontalAlignment = GridHorizontalAlignment.Center; subheaderstyle.CellType = GridCellTypeName.Static; gridControl1.Model.ColWidths[4] = 90; gridControl1.Model.ColWidths[6] = 100; #endregion #region Static Cells gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(1, 1, 2, gridControl1.ColCount)); gridControl1[1, 1] = headerstyle; gridControl1[1, 1].Text = "Static Cells"; int rowIndex = 3, colIndex = 4; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "Static Cells - cannot be edited which represented as a read-only cell"; rowIndex++; gridControl1[rowIndex, colIndex].Text = "Static cell"; gridControl1[rowIndex, colIndex].CellType = GridCellTypeName.Static; gridControl1[rowIndex, colIndex + 2].Text = "Static cell"; gridControl1[rowIndex, colIndex + 2].CellType = GridCellTypeName.Static; gridControl1[rowIndex, colIndex + 2].ImageIndex = 8; #endregion #region ImageCells with PictureBox rowIndex = 7; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Image Cells"; rowIndex = 10; gridControl1[rowIndex, colIndex].CellType = GridCellTypeName.Image; gridControl1[rowIndex, colIndex].ImageList = imageList; gridControl1[rowIndex, colIndex].ImageIndex = 2; gridControl1[rowIndex, colIndex + 1].CellType = GridCellTypeName.Image; gridControl1[rowIndex, colIndex + 1].ImageList = imageList; gridControl1[rowIndex, colIndex + 1].ImageIndex = 4; //gridControl1[rowIndex, colIndex + 2].CellType = GridCellTypeName.Image; //gridControl1[rowIndex, colIndex + 2].ImageList = imageList; //gridControl1[rowIndex, colIndex + 2].ImageIndex = 8; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].CellType = GridCellTypeName.Image; gridControl1[rowIndex, colIndex].ImageList = imageList; gridControl1[rowIndex, colIndex].ImageIndex = 5; gridControl1[rowIndex, colIndex + 1].CellType = GridCellTypeName.Image; gridControl1[rowIndex, colIndex + 1].ImageList = imageList; gridControl1[rowIndex, colIndex + 1].ImageIndex = 7; //gridControl1[rowIndex, colIndex + 2].CellType = GridCellTypeName.Image; //gridControl1[rowIndex, colIndex + 2].ImageList = imageList; //gridControl1[rowIndex, colIndex + 2].ImageIndex = 10; #region ApplyImages // GridStyleInfo style; // style = gridControl1[9, 2]; // style.CellType = "PictureBox"; //#if HELPERCLASS // sp = new Syncfusion.GridHelperClasses.PictureBoxStyleProperties(style); //#else // sp = new PictureBoxStyleProperties(style); //#endif // sp.Image = Image.FromFile(@"..\..\Resources\Car1.jpg"); // sp.SizeMode = PictureBoxSizeMode.StretchImage; // style = gridControl1[9, 6]; // style.CellType = "PictureBox"; //#if HELPERCLASS // sp = new Syncfusion.GridHelperClasses.PictureBoxStyleProperties(style); //#else // sp = new PictureBoxStyleProperties(style); //#endif // sp.Image = Image.FromFile(@"..\..\Resources\car2.jpg"); // sp.SizeMode = PictureBoxSizeMode.StretchImage; #endregion #endregion #region HeaderCells rowIndex = 14; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, 15, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Header Cells"; rowIndex = 16; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "Header Cells - Used as Column Header and RowHeader cells"; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].Text = "Header Text"; gridControl1[rowIndex, colIndex].CellType = GridCellTypeName.Header; gridControl1[rowIndex, colIndex + 2].Text = "Header Text"; gridControl1[rowIndex, colIndex + 2].CellType = GridCellTypeName.Header; #endregion #region ProgressBar Cells rowIndex = 21; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Font.Size = 10; gridControl1[rowIndex, 1].CellType = GridCellTypeName.CheckBox; gridControl1[rowIndex, 1].Description = "ProgressBar Cells"; rowIndex = 24; GridStyleInfo style1 = gridControl1[rowIndex, 2]; GridProgressBarInfo progressBarEx1 = style1.ProgressBar; style1.CellType = "ProgressBar"; style1.Themed = false; style1.BackColor = System.Drawing.SystemColors.Control; style1.CellAppearance = GridCellAppearance.Raised; progressBarEx1.BackGradientEndColor = System.Drawing.SystemColors.ControlLightLight; progressBarEx1.BackGradientStartColor = System.Drawing.SystemColors.ControlDark; progressBarEx1.BackgroundStyle = Syncfusion.Windows.Forms.Tools.ProgressBarBackgroundStyles.VerticalGradient; progressBarEx1.BackMultipleColors = new System.Drawing.Color[] { System.Drawing.SystemColors.ControlDark, System.Drawing.SystemColors.ControlLightLight, System.Drawing.SystemColors.Control }; progressBarEx1.BackSegments = false; progressBarEx1.BackTubeEndColor = System.Drawing.SystemColors.ControlLightLight; progressBarEx1.BackTubeStartColor = System.Drawing.SystemColors.ControlDark; //progressBarEx1.Border3DStyle = System.Windows.Forms.Border3DStyle.RaisedOuter; //progressBarEx1.BorderColor = System.Drawing.Color.Black; progressBarEx1.FontColor = System.Drawing.SystemColors.HighlightText; progressBarEx1.ForeColor = System.Drawing.Color.MediumBlue; progressBarEx1.ForegroundImage = null; progressBarEx1.GradientEndColor = System.Drawing.Color.Lime; progressBarEx1.GradientStartColor = System.Drawing.Color.Red; progressBarEx1.MultipleColors = new System.Drawing.Color[] { System.Drawing.Color.DarkRed, System.Drawing.Color.Red, System.Drawing.Color.Black }; progressBarEx1.ProgressStyle = Syncfusion.Windows.Forms.Tools.ProgressBarStyles.Tube; progressBarEx1.SegmentWidth = 20; progressBarEx1.StretchImage = false; progressBarEx1.StretchMultGrad = false; progressBarEx1.TextShadow = false; progressBarEx1.TubeEndColor = System.Drawing.SystemColors.Control; progressBarEx1.TubeStartColor = System.Drawing.SystemColors.ControlDark; progressBarEx1.ProgressValue = 79; gridControl1.RowHeights[rowIndex] = 23; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 2, rowIndex, 6)); int rowIndex1 = rowIndex; int colIndex1 = 2; gridControl1.ColWidths[8] = 23; // Vertical rowIndex += 2; GridStyleInfo stylev3 = gridControl1[rowIndex, 8]; GridProgressBarInfo progressBarExv3 = stylev3.ProgressBar; stylev3.CellType = "ProgressBar"; stylev3.Themed = false; progressBarExv3.ProgressOrientation = Orientation.Vertical; progressBarExv3.BackGradientEndColor = System.Drawing.Color.White; progressBarExv3.BackGradientStartColor = System.Drawing.Color.LightGray; progressBarExv3.BackgroundStyle = Syncfusion.Windows.Forms.Tools.ProgressBarBackgroundStyles.System; progressBarExv3.BackSegments = false; progressBarExv3.BackTubeEndColor = System.Drawing.Color.White; progressBarExv3.BackTubeStartColor = System.Drawing.Color.LightGray; progressBarExv3.FontColor = System.Drawing.Color.White; progressBarExv3.ForegroundImage = null; progressBarExv3.GradientEndColor = System.Drawing.Color.Lime; progressBarExv3.GradientStartColor = System.Drawing.Color.Red; progressBarExv3.MultipleColors = new System.Drawing.Color[0]; progressBarExv3.ProgressStyle = Syncfusion.Windows.Forms.Tools.ProgressBarStyles.System; progressBarExv3.SegmentWidth = 12; progressBarExv3.TubeEndColor = System.Drawing.Color.Black; progressBarExv3.TubeStartColor = System.Drawing.Color.Red; progressBarExv3.ProgressValue = 75; gridControl1.RowHeights[rowIndex] = 23; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 8, rowIndex + 8, 8)); // Horizontal GridStyleInfo style3 = gridControl1[rowIndex, colIndex1]; GridProgressBarInfo progressBarEx3 = style3.ProgressBar; style3.CellType = "ProgressBar"; style3.Themed = false; progressBarEx3.BackGradientEndColor = System.Drawing.Color.RosyBrown; progressBarEx3.BackGradientStartColor = System.Drawing.Color.DarkRed; progressBarEx3.BackgroundStyle = Syncfusion.Windows.Forms.Tools.ProgressBarBackgroundStyles.VerticalGradient; progressBarEx3.BackMultipleColors = new System.Drawing.Color[0]; progressBarEx3.BackSegments = false; progressBarEx3.BackTubeEndColor = System.Drawing.SystemColors.Control; progressBarEx3.BackTubeStartColor = System.Drawing.Color.LightGray; progressBarEx3.FontColor = System.Drawing.Color.Lime; progressBarEx3.ForegroundImage = null; progressBarEx3.GradientEndColor = System.Drawing.Color.Lime; progressBarEx3.GradientStartColor = System.Drawing.Color.Red; progressBarEx3.MultipleColors = new System.Drawing.Color[] { System.Drawing.SystemColors.ControlDarkDark, System.Drawing.SystemColors.ControlLight, System.Drawing.SystemColors.ControlDark, System.Drawing.SystemColors.Control }; progressBarEx3.ProgressStyle = Syncfusion.Windows.Forms.Tools.ProgressBarStyles.Tube; progressBarEx3.TextVisible = false; progressBarEx3.TubeEndColor = System.Drawing.Color.Black; progressBarEx3.TubeStartColor = System.Drawing.Color.Red; progressBarEx3.ProgressValue = 75; gridControl1.RowHeights[rowIndex] = 23; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 2, rowIndex, 6)); // Horizontal rowIndex += 2; GridStyleInfo style4 = gridControl1[rowIndex, colIndex1]; GridProgressBarInfo progressBarEx4 = style4.ProgressBar; style4.CellType = "ProgressBar"; style4.Themed = false; // // progressBarEx4 // progressBarEx4.BackGradientEndColor = System.Drawing.Color.White; progressBarEx4.BackGradientStartColor = System.Drawing.Color.LightGray; progressBarEx4.ForegroundImage = GetBitmap("Coffee Bean.bmp"); progressBarEx4.BackgroundStyle = Syncfusion.Windows.Forms.Tools.ProgressBarBackgroundStyles.Image; progressBarEx4.BackMultipleColors = new System.Drawing.Color[0]; progressBarEx4.BackSegments = false; progressBarEx4.BackTubeEndColor = System.Drawing.Color.White; progressBarEx4.BackTubeStartColor = System.Drawing.Color.LightGray; progressBarEx4.FontColor = System.Drawing.SystemColors.Control; progressBarEx4.BackgroundImage = GetBitmap("Soap-Bubbles.jpg");; progressBarEx4.GradientEndColor = System.Drawing.Color.Lime; progressBarEx4.GradientStartColor = System.Drawing.Color.Red; progressBarEx4.MultipleColors = new System.Drawing.Color[0]; progressBarEx4.ProgressStyle = Syncfusion.Windows.Forms.Tools.ProgressBarStyles.Image; progressBarEx4.SegmentWidth = 12; progressBarEx4.StretchImage = false; progressBarEx4.TubeEndColor = System.Drawing.Color.Black; progressBarEx4.TubeStartColor = System.Drawing.Color.Red; progressBarEx4.ProgressValue = 75; gridControl1.RowHeights[rowIndex] = 23; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 2, rowIndex, 6)); // Horizontal rowIndex += 2; GridStyleInfo style7 = gridControl1[rowIndex, colIndex1]; GridProgressBarInfo progressBarEx7 = style7.ProgressBar; style7.CellType = "ProgressBar"; style7.Themed = false; // // progressBarEx7 // progressBarEx7.BackGradientEndColor = System.Drawing.SystemColors.ControlLightLight; progressBarEx7.BackGradientStartColor = System.Drawing.SystemColors.ControlDark; progressBarEx7.BackgroundStyle = Syncfusion.Windows.Forms.Tools.ProgressBarBackgroundStyles.VerticalGradient; progressBarEx7.BackMultipleColors = new System.Drawing.Color[0]; progressBarEx7.BackSegments = false; progressBarEx7.BackTubeEndColor = System.Drawing.Color.Silver; progressBarEx7.BackTubeStartColor = System.Drawing.Color.White; progressBarEx7.FontColor = System.Drawing.Color.White; progressBarEx7.ForegroundImage = null; progressBarEx7.GradientEndColor = System.Drawing.Color.Lime; progressBarEx7.GradientStartColor = System.Drawing.Color.Red; progressBarEx7.MultipleColors = new System.Drawing.Color[] { System.Drawing.SystemColors.ControlDarkDark, System.Drawing.SystemColors.ControlLightLight, System.Drawing.SystemColors.ActiveCaption }; progressBarEx7.ProgressStyle = Syncfusion.Windows.Forms.Tools.ProgressBarStyles.Tube; progressBarEx7.SegmentWidth = 8; progressBarEx7.StretchImage = false; progressBarEx7.TextVisible = false; progressBarEx7.TubeEndColor = System.Drawing.Color.Honeydew; progressBarEx7.TubeStartColor = System.Drawing.Color.Green; progressBarEx7.ProgressValue = 75; gridControl1.RowHeights[rowIndex] = 23; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 2, rowIndex, 6)); // Horizontal rowIndex += 2; GridStyleInfo style9 = gridControl1[rowIndex, colIndex1]; GridProgressBarInfo progressBarEx9 = style9.ProgressBar; style9.CellType = "ProgressBar"; style9.Themed = false; // // progressBarEx9 // progressBarEx9.BackGradientEndColor = System.Drawing.Color.White; progressBarEx9.BackGradientStartColor = System.Drawing.Color.LightGray; progressBarEx9.BackgroundStyle = Syncfusion.Windows.Forms.Tools.ProgressBarBackgroundStyles.Tube; progressBarEx9.BackMultipleColors = new System.Drawing.Color[0]; progressBarEx9.BackSegments = false; progressBarEx9.BackTubeEndColor = System.Drawing.Color.White; progressBarEx9.BackTubeStartColor = System.Drawing.Color.LightGray; progressBarEx9.ForegroundImage = null; progressBarEx9.GradientEndColor = System.Drawing.Color.Yellow; progressBarEx9.GradientStartColor = System.Drawing.Color.Red; progressBarEx9.MultipleColors = new System.Drawing.Color[0]; progressBarEx9.ProgressStyle = Syncfusion.Windows.Forms.Tools.ProgressBarStyles.Gradient; progressBarEx9.SegmentWidth = 12; progressBarEx9.TubeEndColor = System.Drawing.Color.Black; progressBarEx9.TubeStartColor = System.Drawing.Color.Red; progressBarEx9.ProgressValue = 75; gridControl1.RowHeights[rowIndex] = 23; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 2, rowIndex, 6)); // Horizontal rowIndex += 2; GridStyleInfo style14 = gridControl1[rowIndex, colIndex1]; GridProgressBarInfo progressBarEx14 = style14.ProgressBar; style14.CellType = "ProgressBar"; style14.Themed = true; // // progressBarEx14 // progressBarEx14.BackGradientEndColor = System.Drawing.Color.White; progressBarEx14.BackGradientStartColor = System.Drawing.Color.LightGray; progressBarEx14.BackgroundStyle = Syncfusion.Windows.Forms.Tools.ProgressBarBackgroundStyles.System; progressBarEx14.BackSegments = false; progressBarEx14.BackTubeEndColor = System.Drawing.Color.White; progressBarEx14.BackTubeStartColor = System.Drawing.Color.LightGray; progressBarEx14.FontColor = System.Drawing.Color.White; progressBarEx14.ForegroundImage = null; progressBarEx14.GradientEndColor = System.Drawing.Color.FromArgb(255, 187, 111); progressBarEx14.GradientStartColor = System.Drawing.Color.FromArgb(0, 21, 84); progressBarEx14.MultipleColors = new System.Drawing.Color[0]; progressBarEx14.ProgressStyle = Syncfusion.Windows.Forms.Tools.ProgressBarStyles.WaitingGradient; progressBarEx14.SegmentWidth = 12; progressBarEx14.TubeEndColor = System.Drawing.Color.Black; progressBarEx14.TubeStartColor = System.Drawing.Color.Red; progressBarEx14.ProgressValue = 75; gridControl1.RowHeights[rowIndex] = 23; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 2, rowIndex, 6)); rowIndex += 2; GridStyleInfo styleCheckBox = gridControl1[rowIndex, colIndex1]; styleCheckBox.CellType = "CheckBox"; styleCheckBox.Description = "Animate"; styleCheckBox.Themed = true; styleCheckBox.CellValue = "False"; styleCheckBox.CheckBoxOptions.UncheckedValue = "False"; styleCheckBox.CheckBoxOptions.CheckedValue = "True"; styleCheckBox.FloatCell = true; //gridControl1.CurrentCellChanged += new EventHandler(gridControl1_CurrentCellChanged); gridControl1.CheckBoxClick += new GridCellClickEventHandler(gridControl1_CheckBoxClick); for (int i = 23; i <= 36; i++) { gridControl1.HideRows[i] = true; } #endregion this.gridControl1.EndUpdate(true); #endregion }
private void InitializeGrid() { #region Style prerequistes GridStyleInfo standard = gridControl1.BaseStylesMap["Standard"].StyleInfo; standard.Font.Bold = false; standard.Font.Facename = "Verdana"; //"Verdana"; standard.Font.Size = 10; standard.TextColor = Color.FromArgb(240, 0, 21, 84); gridControl1.Font = new System.Drawing.Font("Verdana", 8.5F); // grab some images... ImageList imageList = new ImageList(); imageList.Images.Add(SystemIcons.Warning.ToBitmap()); imageList.Images.Add(SystemIcons.Application.ToBitmap()); imageList.Images.Add(SystemIcons.Asterisk.ToBitmap()); imageList.Images.Add(SystemIcons.Error.ToBitmap()); imageList.Images.Add(SystemIcons.Exclamation.ToBitmap()); imageList.Images.Add(SystemIcons.Hand.ToBitmap()); imageList.Images.Add(SystemIcons.Information.ToBitmap()); imageList.Images.Add(SystemIcons.Question.ToBitmap()); //standard.ImageList = imageList; Icon icon = new Icon(GetType().Module.Assembly.GetManifestResourceStream("EditorCellDemo.gridform.ico")); imageList.Images.Add(icon.ToBitmap()); icon = new Icon(GetType().Module.Assembly.GetManifestResourceStream("EditorCellDemo.toolsform.ico")); imageList.Images.Add(icon.ToBitmap()); standard.ImageList = imageList; #endregion #region Codes to apply celltypes in Grid this.gridControl1.BeginUpdate(); gridControl1.TableStyle.FloatCell = true; gridControl1.FloatCellsMode = GridFloatCellsMode.BeforeDisplayCalculation; #region Style declaration GridStyleInfo headerstyle = new GridStyleInfo(); headerstyle.Font.Size = 12; headerstyle.Font.Bold = true; headerstyle.VerticalAlignment = GridVerticalAlignment.Middle; headerstyle.HorizontalAlignment = GridHorizontalAlignment.Center; headerstyle.CellType = GridCellTypeName.Static; GridStyleInfo subheaderstyle = new GridStyleInfo(); subheaderstyle.Font.Bold = true; subheaderstyle.VerticalAlignment = GridVerticalAlignment.Middle; subheaderstyle.HorizontalAlignment = GridHorizontalAlignment.Center; subheaderstyle.CellType = GridCellTypeName.Static; subheaderstyle.TextColor = Color.Gray; gridControl1.Model.ColWidths[4] = 90; gridControl1.Model.ColWidths[6] = 100; #endregion #region TextBox Cells gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(1, 1, 2, gridControl1.ColCount)); gridControl1[1, 1] = headerstyle; gridControl1[1, 1].Text = "TextBox Cells"; int rowIndex = 3, colIndex = 4; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "TextBox Cells - represents the default textbox control in a cell as used for in - place editing"; rowIndex++; gridControl1[rowIndex, colIndex].Text = "TextBox"; gridControl1[rowIndex, colIndex].CellType = GridCellTypeName.TextBox; gridControl1[rowIndex, colIndex + 2].Text = "TextBox/Image"; gridControl1[rowIndex, colIndex + 2].CellType = GridCellTypeName.TextBox; gridControl1[rowIndex, colIndex + 2].ImageIndex = 9; gridControl1.Model.ColWidths.ResizeToFit(GridRangeInfo.Col(colIndex + 2)); #endregion #region MaskEditCells rowIndex += 2; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "MaskEdit Cells"; rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "MaskEdit Cells - allow to mask any cell that permits valid inputs & also control the inputs values"; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].Text = "Date Format"; gridControl1[rowIndex, colIndex + 2].CellType = GridCellTypeName.MaskEdit; gridControl1[rowIndex, colIndex + 2].MaskEdit.Mask = "99-99-99"; gridControl1[rowIndex, colIndex + 2].FloatCell = true; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].Text = "First Name"; GridStyleInfo style1 = gridControl1[rowIndex, colIndex + 2]; GridMaskEditInfo maskedEditStyle1 = style1.MaskEdit; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].Text = "Last Name"; GridStyleInfo style2 = gridControl1[rowIndex, colIndex + 2]; GridMaskEditInfo maskedEditStyle2 = style2.MaskEdit; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].Text = "Telephone"; GridStyleInfo style3 = gridControl1[rowIndex, colIndex + 2]; GridMaskEditInfo maskedEditStyle3 = style3.MaskEdit; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].Text = "Social Security"; GridStyleInfo style4 = gridControl1[rowIndex, colIndex + 2]; GridMaskEditInfo maskedEditStyle4 = style4.MaskEdit; #region MaskEditBoxes // // maskedEditBox1 // style1.CellType = "MaskEdit"; maskedEditStyle1.AllowPrompt = false; maskedEditStyle1.ClipMode = Syncfusion.Windows.Forms.Tools.ClipModes.ExcludeLiterals; style1.CultureInfo = new System.Globalization.CultureInfo("en-US"); maskedEditStyle1.DateSeparator = '-'; maskedEditStyle1.Mask = ">C<CCCCCCCCCCCC"; style1.MaxLength = 13; style1.AutoSize = true; maskedEditStyle1.SpecialCultureValue = Syncfusion.Windows.Forms.Tools.SpecialCultureValues.None; maskedEditStyle1.UseLocaleDefault = false; maskedEditStyle1.UseUserOverride = true; // // maskedEditBox2 // style2.CellType = "MaskEdit"; maskedEditStyle2.AllowPrompt = false; maskedEditStyle2.ClipMode = Syncfusion.Windows.Forms.Tools.ClipModes.IncludeLiterals; style2.CultureInfo = new System.Globalization.CultureInfo("en-US"); maskedEditStyle2.DateSeparator = '-'; maskedEditStyle2.Mask = "CCCCCCCCCCCCC"; style2.MaxLength = 13; maskedEditStyle2.SpecialCultureValue = Syncfusion.Windows.Forms.Tools.SpecialCultureValues.None; style2.Text = "_____________"; maskedEditStyle2.UseLocaleDefault = false; maskedEditStyle2.UseUserOverride = true; // // maskedEditBox3 // style3.CellType = "MaskEdit"; maskedEditStyle3.AllowPrompt = false; maskedEditStyle3.ClipMode = Syncfusion.Windows.Forms.Tools.ClipModes.IncludeLiterals; style3.CultureInfo = new System.Globalization.CultureInfo("en-US"); maskedEditStyle3.DateSeparator = '-'; maskedEditStyle3.Mask = "(999) 999 - 9999"; style3.MaxLength = 16; maskedEditStyle3.SpecialCultureValue = Syncfusion.Windows.Forms.Tools.SpecialCultureValues.None; style3.Text = "(___) ___ - ____"; maskedEditStyle3.UseLocaleDefault = false; maskedEditStyle3.UseUserOverride = true; // // maskedEditBox4 // style4.CellType = "MaskEdit"; maskedEditStyle4.AllowPrompt = false; maskedEditStyle4.ClipMode = Syncfusion.Windows.Forms.Tools.ClipModes.IncludeLiterals; style4.CultureInfo = new System.Globalization.CultureInfo("en-US"); maskedEditStyle4.DateSeparator = '-'; maskedEditStyle4.Mask = "999-99-9999"; style4.MaxLength = 11; maskedEditStyle4.SpecialCultureValue = Syncfusion.Windows.Forms.Tools.SpecialCultureValues.None; style4.Text = "___-__-____"; maskedEditStyle4.UseLocaleDefault = false; maskedEditStyle4.UseUserOverride = true; #endregion #endregion #region NumericUpDown rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "NumericUpDown Cells"; rowIndex += 3; // Wrapping, Range 0-20 gridControl1[rowIndex, colIndex].Text = "With wrapping"; gridControl1[rowIndex, colIndex + 2].CellType = GridCellTypeName.NumericUpDown; gridControl1[rowIndex, colIndex + 2].Text = "5"; gridControl1[rowIndex, colIndex + 2].HorizontalAlignment = GridHorizontalAlignment.Right; gridControl1[rowIndex, colIndex + 2].NumericUpDown = new GridNumericUpDownCellInfo(0, 20, 5, 1, true); rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].Text = "Without wrapping"; gridControl1[rowIndex, colIndex + 2].CellType = GridCellTypeName.NumericUpDown; gridControl1[rowIndex, colIndex + 2].Text = "5"; gridControl1[rowIndex, colIndex + 2].NumericUpDown = new GridNumericUpDownCellInfo(1, 20, 1, 1, false); gridControl1[rowIndex, colIndex + 2].HorizontalAlignment = GridHorizontalAlignment.Right; #endregion #region Currency Cells rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Currency Cells"; rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "Supports setting patterns to display (+), (-) numbers, grouping digits & decimal separators"; #region CurrentStyle Settings GridStyleInfo currencyStyle = new GridStyleInfo(); currencyStyle.CellType = GridCellTypeName.Currency; currencyStyle.CurrencyEdit.ClipMode = CurrencyClipModes.ExcludeFormatting; // Set formatting properties currencyStyle.CurrencyEdit.NullString = ""; currencyStyle.CurrencyEdit.CurrencyDecimalDigits = 2; currencyStyle.CurrencyEdit.CurrencyDecimalSeparator = "."; currencyStyle.CurrencyEdit.CurrencyGroupSeparator = ","; currencyStyle.CurrencyEdit.CurrencyGroupSizes = new int[] { 3 }; currencyStyle.CurrencyEdit.CurrencyNumberDigits = 27; currencyStyle.CurrencyEdit.CurrencyPositivePattern = 0; //currencyStyle.CurrencyEdit.CurrencySymbol = (row % 2 == 0) ? "$ " : "DM "; currencyStyle.TextColor = System.Drawing.Color.Black; currencyStyle.CurrencyEdit.NegativeColor = System.Drawing.Color.Red; currencyStyle.CurrencyEdit.NegativeSign = "-"; currencyStyle.CurrencyEdit.PositiveColor = System.Drawing.Color.Black; currencyStyle.FloatCell = true; #endregion rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex - 2] = currencyStyle; gridControl1[rowIndex, colIndex - 2].CellValue = 2; gridControl1[rowIndex, colIndex - 2].CurrencyEdit.CurrencyNegativePattern = 1; gridControl1[rowIndex, colIndex - 2].CurrencyEdit.CurrencySymbol = "$ "; gridControl1[rowIndex, colIndex] = currencyStyle; gridControl1[rowIndex, colIndex].CellValue = 4; gridControl1[rowIndex, colIndex].CurrencyEdit.CurrencyNegativePattern = 2; gridControl1[rowIndex, colIndex].CurrencyEdit.CurrencySymbol = "DM"; gridControl1[rowIndex, colIndex + 2] = currencyStyle; gridControl1[rowIndex, colIndex + 2].CellValue = -6; gridControl1[rowIndex, colIndex + 2].CurrencyEdit.CurrencyNegativePattern = 1; gridControl1[rowIndex, colIndex + 2].CurrencyEdit.CurrencySymbol = "$ "; gridControl1[rowIndex, colIndex + 4] = currencyStyle; gridControl1[rowIndex, colIndex + 4].CellValue = -8; gridControl1[rowIndex, colIndex + 4].CurrencyEdit.CurrencyNegativePattern = 2; gridControl1[rowIndex, colIndex + 4].CurrencyEdit.CurrencySymbol = "DM "; #endregion #region Password cells rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Password Cells"; rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "Allows you to type a password, but only masking character like \" * \", will be displayed "; GridStyleInfo passwdStyle = new GridStyleInfo(); for (int row = 37; row <= 45; row++) { passwdStyle = gridControl1[row, 2]; passwdStyle.PasswordChar = '*'; passwdStyle.CellType = GridCellTypeName.OriginalTextBox; passwdStyle.Text = new string((char)(65 + row), row); passwdStyle = gridControl1[row, 3]; passwdStyle.CharacterCasing = CharacterCasing.Lower; passwdStyle.Text = new string((char)(65 + row), row); passwdStyle = gridControl1[row, 4]; passwdStyle.CharacterCasing = CharacterCasing.Upper; passwdStyle.Text = new string((char)(65 + row), row); } #endregion gridControl1.CheckBoxClick += new GridCellClickEventHandler(gridControl1_CheckBoxClick); gridControl1.Model.ColWidths.ResizeToFit(GridRangeInfo.Cols(1, 11)); gridControl1.Model.ColWidths[0] = (int)DpiAware.LogicalToDeviceUnits(35); this.gridControl1.EndUpdate(true); #endregion }