public GridSpeedSearch(DBGridBase gridControl, ToolStripTextBox findControl) { _grid = gridControl; txtFind = findControl; txtFind.ToolTipText = "Быстрый поиск"; //txtFind.TextChanged += new EventHandler(txtFind_TextChanged); txtFind.Validated += new EventHandler(txtFind_TextChanged); txtFind.Leave += new EventHandler((sender, e) => { searchColName = string.Empty; }); txtFind.KeyDown += new KeyEventHandler((sender, e) => { if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Down) { _grid.Focus(); } }); _grid.KeyPress += new KeyPressEventHandler((sender, e) => { if (char.IsLetterOrDigit(e.KeyChar)) { txtFind.Focus(); SendKeys.Send("{END}"); txtFind.Text += e.KeyChar.ToString(); } }); _grid.KeyDown += (sender, e) => { if (e.KeyCode == Keys.Back) { int len; string text = txtFind.Text; if ((len = text.Length) > 1) { txtFind.Text = text.Left(len - 1); txtFind.Focus(); SendKeys.Send("{END}"); } else { this.Clear(); } } }; errToolTip = new ToolTip { ToolTipIcon = ToolTipIcon.Error }; }
static StiReport MakeReport(DBGrid grid, ReportCreateParam param) { JMXSchema schema = grid.Schema; DataTable dt = grid.BaseTable; double top = 0; float fontSize = param.FontSize; string tableName = TableAliasDefault;; StiReport report = new StiReport { ScriptLanguage = StiReportLanguageType.CSharp, ReportName = schema.Name }; //report.RegData(tableName, dt); report.RegData(tableName, grid.GetBindingSource()); report.Dictionary.Synchronize(); report.Dictionary.DataSources[0].Name = tableName; report.Dictionary.DataSources[0].Alias = tableName; StiPage page = report.Pages.Items[0]; page.Margins.Left = 1; page.Margins.Right = 1; page.AlignToGrid(); //ReportTitle bool titleOnPage = param.TitleOnPage; StiReportTitleBand titleBand = new StiReportTitleBand { Height = 0.5f, CanGrow = true, Name = "TitleBand" }; page.Components.Add(titleBand); //Period bool period = param.Period; if (period) { StiText periodText = new StiText(new RectangleD(0, 0, page.Width, 0.5f)); periodText.Text.Value = rth.Za(); periodText.HorAlignment = StiTextHorAlignment.Right; periodText.Name = "periodText"; periodText.Border.Side = StiBorderSides.None; //periodText.DockStyle = StiDockStyle.Right; periodText.Font = new Font(grid.Font.FontFamily.Name, fontSize, FontStyle.Bold); titleBand.Components.Add(periodText); top += periodText.Height; } //Title StiText titleText = new StiText(new RectangleD(0, period ? 0.5f : 0, page.Width, 1f)); titleText.Text.Value = grid.Schema.Name; titleText.HorAlignment = StiTextHorAlignment.Center; titleText.Name = "titleText"; titleText.Border.Side = StiBorderSides.None; titleText.Font = new Font(grid.Font.FontFamily.Name, 12f, FontStyle.Bold); titleText.WordWrap = true; titleText.CanGrow = true; titleBand.Components.Add(titleText); top += titleText.Height; //Create HeaderBand StiBand headBand; StiHeaderBand headerBand = new StiHeaderBand { Height = 0.5f, Name = "HeaderBand" }; if (titleOnPage) { page.Components.Add(headerBand); headBand = headerBand; } else { headBand = titleBand; } //Create Databand StiDataBand dataBand = new StiDataBand { DataSourceName = tableName, Height = 0.5f, Name = "DataBand" }; page.Components.Add(dataBand); //Create FooterBand StiFooterBand footerBand = new StiFooterBand { Height = 0.5f, CanGrow = true, Name = "FooterBand", CanBreak = false }; page.Components.Add(footerBand); Double pos = 0; int nameIndex = 1; int i = 0; bool multiLine = param.MultiLine; int border = param.Border; bool totals = false; List <StiText> footerList = new List <StiText>(); foreach (DataGridViewColumn column in grid.Columns) { bool visible = (column.Visible && column.Width > 1); if (visible) { Double columnWidth = StiAlignValue.AlignToMinGrid(column.Width / 33, 0.03, true); //Create text on header StiText headerText = new StiText(new RectangleD(pos, titleOnPage ? 0: top, columnWidth, 0.5f)); headerText.Text.Value = column.HeaderText; headerText.HorAlignment = StiTextHorAlignment.Center; headerText.Name = "HeaderText" + nameIndex.ToString(); if (border == 0) { headerText.Border.Side = StiBorderSides.Top | StiBorderSides.Bottom; } else { headerText.Border.Side = StiBorderSides.All; } headerText.CanGrow = true; headerText.GrowToHeight = true; headerText.WordWrap = multiLine; headerText.Font = new Font(grid.ColumnHeadersDefaultCellStyle.Font.FontFamily.Name, fontSize); headBand.Components.Add(headerText); MacroType tt = DBGridBase.GetMacroType(schema.Attributes[i].DataType); string format = column.DefaultCellStyle.Format; if (string.IsNullOrEmpty(format) && tt == MacroType.date) { format = vbo.DateFormat; } StiTextHorAlignment horAlign; switch (column.DefaultCellStyle.Alignment) { case DataGridViewContentAlignment.MiddleRight: horAlign = StiTextHorAlignment.Right; break; case DataGridViewContentAlignment.MiddleLeft: horAlign = StiTextHorAlignment.Left; break; default: horAlign = StiTextHorAlignment.Center; break; } //Create text on Data Band StiText dataText = new StiText(new RectangleD(pos, 0, columnWidth, 0.5f)); string field = tableName + "." + Stimulsoft.Report.CodeDom.StiCodeDomSerializator.ReplaceSymbols(column.DataPropertyName); if (AccntFormat.ValidFormat(format)) { dataText.Text.Value = "{Substring(" + field + ",0,5)+" + "-".Qt() + "+Substring(" + field + ",5,3)+" + "-".Qt() + "+Substring(" + field + ",8,1)+" + "-".Qt() + "+Substring(" + field + ",9,4)+" + "-".Qt() + "+Substring(" + field + ",13,7)" + "}"; } else { dataText.Text.Value = "{" + field + "}"; } dataText.Name = "DataText" + nameIndex.ToString(); dataText.CanGrow = true; dataText.GrowToHeight = true; dataText.WordWrap = multiLine; dataText.HorAlignment = horAlign; //dataText.VertAlignment = StiVertAlignment.Center; if (border == 0) { dataText.Border.Side = StiBorderSides.None; } else if (border == 1) { dataText.Border.Side = StiBorderSides.Bottom; } else { dataText.Border.Side = StiBorderSides.All; } if (grid.RowsDefaultCellStyle.Font == null) { dataText.Font = new Font(grid.Font.FontFamily.Name, fontSize); } else { dataText.Font = new Font(grid.RowsDefaultCellStyle.Font.FontFamily.Name, fontSize); } dataText.TextFormat = ParseFormat(format); if (tt == MacroType.num) { dataText.ExcelValue.Value = "{" + field + "}"; } dataBand.Components.Add(dataText); //Create text on footer string summary = schema.Attributes[i].Agregate.ToLower(); if (summary == "sum") { summary = "Sum(" + field + ")"; } else if (summary == "rcnt") { summary = "Count()"; } else if (summary == "ave") { summary = "Avg(" + field + ")"; } else if (summary == "min") { summary = "Min(" + field + ")"; } else if (summary == "max") { summary = "Max(" + field + ")"; } else { summary = string.Empty; } bool summaryEmpty = string.IsNullOrEmpty(summary); int footerIndex = i; //if (!string.IsNullOrEmpty(grid.FooterText(footerIndex))) if (!summaryEmpty) { totals = true; } StiText footerText = new StiText(new RectangleD(pos, 0, columnWidth, 0.5f)); if (footerIndex == 0 && summaryEmpty) { footerText.Text.Value = grid.FooterCaption; } else if (footerIndex == 0) { footerText.Text.Value = "{" + (grid.FooterCaption + vbo.vbTab).Qt() + "+" + summary + "}"; } else if (!summaryEmpty) { footerText.Text.Value = "{" + summary + "}"; footerText.ExcelValue.Value = "{" + summary + "}"; } else { footerText.Text.Value = grid.FooterText(footerIndex); } footerText.Name = "FooterText" + nameIndex.ToString(); if (border == 0) { footerText.Border.Side = StiBorderSides.Top | StiBorderSides.Bottom; } else { footerText.Border.Side = StiBorderSides.All; } if (!summaryEmpty && summary != "Count()") { footerText.TextFormat = (StiFormatService)dataText.TextFormat.Clone(); } footerText.HorAlignment = horAlign; //footerText.VertAlignment = StiVertAlignment.Center; footerText.Font = new Font(grid.Font.FontFamily.Name, fontSize); footerList.Add(footerText); pos += columnWidth; nameIndex++; } i++; } if (totals) { footerBand.Components.AddRange(footerList.ToArray()); } if ((pos - page.Width) < 1.6f) { page.Margins.Right = 0; page.Margins.Left /= 2; } else if (pos > page.Width) { page.Orientation = StiPageOrientation.Landscape; titleText.Width = page.Width; if (period) { titleBand.Components[titleBand.Components.IndexOf("periodText")].Width = page.Width; } if (pos > page.Width) { page.Margins.Right = 0; page.Margins.Left /= 2; } if (pos > page.Width) { page.Width = pos; } } if (param.Sign) { footerList.Clear(); //StiText footerText = new StiText(new RectangleD(0, 0.5f, page.Width, 0.5f)); //footerList.Add(footerText); //footerText = new StiText(new RectangleD(0, 1f, page.Width / 2, 0.5f)); //footerText.Text.Value = "{CSetup.Setup.Properties(" + vbo.Qt("President") + ", " + vbo.Qt("") + ")}"; //footerText.HorAlignment = StiTextHorAlignment.Right; //footerText.Font = new Font(grid.ColumnHeadersDefaultCellStyle.Font.FontFamily.Name, 10); //footerList.Add(footerText); //footerText = new StiText(new RectangleD(page.Width / 2, 1f, page.Width / 4, 0.5f)); //footerList.Add(footerText); //footerText = new StiText(new RectangleD(page.Width * 3 / 4, 1f, page.Width / 4, 0.5f)); //footerText.Text.Value = "{CSetup.Setup.Properties(" + vbo.Qt("PresidentName") + ", " + vbo.Qt("") + ")}"; //footerText.HorAlignment = StiTextHorAlignment.Left; //footerText.Font = new Font(grid.ColumnHeadersDefaultCellStyle.Font.FontFamily.Name, 10); //footerList.Add(footerText); //footerText = new StiText(new RectangleD(0, 1.5f, page.Width, 0.5f)); //footerList.Add(footerText); //footerText = new StiText(new RectangleD(0, 2f, page.Width / 2, 0.5f)); //footerText.Text.Value = "{CSetup.Setup.Properties(" + vbo.Qt("ChifAccount") + ", " + vbo.Qt("") + ")}"; //footerText.HorAlignment = StiTextHorAlignment.Right; //footerText.Font = new Font(grid.ColumnHeadersDefaultCellStyle.Font.FontFamily.Name, 10); //footerList.Add(footerText); //footerText = new StiText(new RectangleD(page.Width / 2, 2f, page.Width / 4, 0.5f)); //footerList.Add(footerText); //footerText = new StiText(new RectangleD(page.Width * 3 / 4, 2f, page.Width / 4, 0.5f)); //footerText.Text.Value = "{CSetup.Setup.Properties(" + vbo.Qt("ChifAccountName") + ", " + vbo.Qt("") + ")}"; //footerText.HorAlignment = StiTextHorAlignment.Left; //footerText.Font = new Font(grid.ColumnHeadersDefaultCellStyle.Font.FontFamily.Name, 10); //footerList.Add(footerText); //footerBand.Height = 2.5f; //footerBand.Components.AddRange(footerList.ToArray()); } return(report); }
protected virtual void OnConfigureGrid(DBGridBase dg) { }
protected virtual void OnPopulateGrid(DBGridBase dg) { }
protected virtual void OnGrid2Object(DBGridBase dg) { }