There are 9 columns in datagridview when I print using dgvprinter it prints 7 columns on 1 page and other 2 on a new page. I want to print on a single page anybody helps me?
Note: There is an image on datagridview.
Here is code:
DGVPrinter printer = new DGVPrinter();
printer.Title = "Test";
printer.SubTitle = "Outgoing Stocks";
printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
printer.PageNumbers = true;
printer.PageNumberInHeader = false;
printer.PorportionalColumns = true;
printer.HeaderCellAlignment = StringAlignment.Near;
printer.Footer = "System generated file";
printer.FooterSpacing = 15;
printer.PorportionalColumns = true;
printer.HeaderCellAlignment = StringAlignment.Near;
printer.printDocument.DefaultPageSettings.Landscape = true;
printer.RowHeight = DGVPrinter.RowHeightSetting.CellHeight;
printer.PrintDataGridView(itemdata_datagridview);
Related
I have created a pivot table using Closed XML. I want to change the font name and size of the pivot table (cells). When I try doing so, it changes the font name and size of the outer sheet (not of the cell content in pivot table). I also tried setting the font name of each cell but couldn't work. Below is the part of my code -
public void CreatePivotTable(List<EmployeeModel> employeeModels)
{
var workbook = new XLWorkbook();
var sheet = workbook.Worksheets.Add("SourceData");
var table = sheet.Cell(1, 1).InsertTable(employeeModels, "SourceData", true);
var sheetName = "PivotTable";
var ptSheet = workbook.Worksheets.Add(sheetName);
ptSheet.Style.Font.FontName = "Arial";
ptSheet.Style.Font.FontSize = 8;
var pt = ptSheet.PivotTables.Add(sheetName, ptSheet.Cell(5, 2), table.AsRange());
// pt.SetPreserveCellFormatting(false);
pt.RowLabels.Add("EmpId").Compact = true;
pt.RowLabels.Add("EmpName");
pt.ColumnLabels.Add("Description");
pt.ColumnLabels.Add("Department");
pt.Values.Add("HR", "Sum of HR");
pt.Values.Add("MT", "Sum of MT");
pt.SetShowGrandTotalsRows(false);
ptSheet.Cell(1, 3).Value = DateTime.Now.ToString();
ptSheet.Cell(2, 3).Style.Font.Bold = true;
ptSheet.Columns().Width = 11;
ptSheet.Columns("C").Width = 25;
ptSheet.Columns("A").Width = 1;
ptSheet.Columns("B").Width = 0;
ptSheet.Columns("1,2").Hide();
ptSheet.SheetView.FreezeColumns(4);
ptSheet.SheetView.FreezeRows(7);
ptSheet.Rows(1, 4).Hide();
ptSheet.Rows(4, 4).Unhide();
pt.Theme = XLPivotTableTheme.None;
pt.SetClassicPivotTableLayout(true);
//Print Options.
PrintOptionsForPivotTable(ptSheet);
workbook.SaveAs(#"C:\Users\prags\source\repos\WindowsFormsApp1\ClosedXmlPivotTable\pivot.xlsx");
}
generate html content to pdf using IronPdf, but in pdf generate 3 pages header content and footer in separate pages , how to display in single page hole content.
var Renderer = new IronPdf.HtmlToPdf();
//Renderer.PrintOptions.Header.DrawDividerLine = false;
//Renderer.PrintOptions.Footer.DrawDividerLine = false;
Renderer.PrintOptions.PaperSize = PdfPrintOptions.PdfPaperSize.A4;
Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Screen;
Renderer.PrintOptions.PaperOrientation = PdfPrintOptions.PdfPaperOrientation.Portrait;
// Renderer.PrintOptions.MarginTop = 10; //millimeters
// Renderer.PrintOptions.MarginBottom = 10;
Renderer.PrintOptions.Zoom = 125;
//Renderer.PrintOptions.FirstPageNumber = 1;
Renderer.PrintOptions.CreatePdfFormsFromHtml = true;
Renderer.PrintOptions.FitToPaperWidth = true;
Renderer.PrintOptions.InputEncoding = Encoding.UTF8;
Renderer.PrintOptions.FitToPaperWidth = true;
pdf will be generate like this: enter image description here
Add the header and footer as follows:
var PDF = Renderer.RenderHTMLFileAsPdf("HTML Body");
PDF.AddHTMLHeaders(new HtmlHeaderFooter() {
HtmlFragment = "HTMLHeader"
});
PDF.AddHTMLFooters(new HtmlHeaderFooter()
{
Height=20,
HtmlFragment = "HTML Footer"
});
https://ironpdf.com/object-reference/api/IronPdf.PdfDocument.html?q=AddHTMLHeaders#IronPdf_PdfDocument_AddHTMLHeaders_IronPdf_HtmlHeaderFooter_System_Double_System_Double_System_Double_System_Boolean_System_Collections_Generic_IEnumerable_System_Int32__
I am using a windows forms RichTextEditBox. I load a RTF file into the control. I then set the following code.
int indexToText = rteb.Find("here");
LinkLabel link = new LinkLabel();
link.Text = "here";
link.LinkBehavior = LinkBehavior.AlwaysUnderline;
link.LinkClicked += new
LinkLabelLinkClickedEventHandler(this.link_LinkClicked);
LinkLabel.Link data = new LinkLabel.Link();
data.LinkData = "Sending Report Results to Multiple Recipients.pdf";
link.Links.Add(data);
link.AutoSize = true;
link.Location = rteb.GetPositionFromCharIndex(indexToText);
link.Height = 40;
link.Width = 60;
link.ForeColor = Color.Blue;
rteb.Controls.Add(link);
when the app is run, the word "here" is in blue, but I don't get an underline and when I try clicking on the word, my click event doesn't fire off. What am I missing here?
To set an underlined link area in LinkLabel you should set LinkArea property to the range which should be shown as link, for example:
LinkLabel link = new LinkLabel();
link.Text = "here";
link.LinkArea = new LinkArea(0, link.Text.Length);
link.LinkBehavior = LinkBehavior.AlwaysUnderline;
I have been developing an application using winforms c# .net 4.0.
this application use datagridview and i add combobox + textbox to the datagridview.
During binddata and resizing actions, a black rectangle will draw in the bottom portion of the datagridview.
see the image of the problems
it works perfectly on standard DPI, but problem on the high DPI.
here is the some of my code to binddata and resizing.
using (Class1.Connection = new OleDbConnection(Class1.ConnString))
{
string sql1 = "SELECT tbAuditDetails.AuditNo, tbAuditQuestions.AutoSubcontent, tbAuditQuestions.AutoID, tbAuditQuestions.Questions, tbScore.Description, tbAuditDetails.QuestionID, tbAuditQuestions.QuestAutoID, tbAuditDetails.ScoreID, tbScore.Score, tbAuditQuestions.SubContentID, tbAuditDetails.ProfileID, tbAuditDetails.ScoreRanges, tbAuditDetails.Comments FROM (tbAuditDetails INNER JOIN tbAuditQuestions ON tbAuditDetails.QuestionID = tbAuditQuestions.QuestionID) INNER JOIN tbScore ON tbAuditDetails.ScoreID = tbScore.ScoreID WHERE (([tbAuditDetails.AuditNo] = " + Class1.detailsauditno + ") AND ([tbAuditQuestions.AutoSubcontent] = '" + newautosubcontentid + "') AND ([tbAuditDetails.ProfileID] = " + proid + ")) ORDER BY [tbAuditQuestions.QuestAutoID], [tbAuditDetails.QuestionID]";
Class1.Connection.Open();
oleCommand = new OleDbCommand(sql1, Class1.Connection);
oleAdapter = new OleDbDataAdapter(oleCommand);
oleBuilder = new OleDbCommandBuilder(oleAdapter);
oleDs = new DataSet();
oleAdapter.Fill(oleDs, "tbAuditDetails");
oleTable = oleDs.Tables["tbAuditDetails"];
Class1.Connection.Close();
dataGridView1.DataSource = oleDs.Tables["tbAuditDetails"];
//SET DATAGRIDVIEW
dataGridView1.Columns[0].Visible = false;
dataGridView1.Columns[4].Visible = false;
dataGridView1.Columns[5].Visible = false;
dataGridView1.Columns[6].Visible = false;
dataGridView1.Columns[7].Visible = false;
dataGridView1.Columns[8].Visible = false;
dataGridView1.Columns[9].Visible = false;
dataGridView1.Columns[10].Visible = false;
dataGridView1.Columns[1].HeaderText = " ";
dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridView1.Columns[1].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
dataGridView1.Columns[1].ReadOnly = true;
dataGridView1.Columns[1].Width = 40;
dataGridView1.Columns[2].HeaderText = "ID";
dataGridView1.Columns[2].Width = 40;
dataGridView1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridView1.Columns[2].ReadOnly = true;
dataGridView1.Columns[3].Width = 600;
dataGridView1.Columns[3].ReadOnly = true;
dataGridView1.Columns[3].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
dataGridView1.Columns[11].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridView1.Columns[11].HeaderText = "Score";
dataGridView1.Columns[12].Width = 220;
for (int iii = 0; iii < dataGridView1.Rows.Count; iii++)
{
DataGridViewComboBoxCell ComboBoxCell2 = new DataGridViewComboBoxCell();
ComboBoxCell2.Items.Add("0");
ComboBoxCell2.Items.Add("10");
ComboBoxCell2.Items.Add("20");
ComboBoxCell2.Items.Add("30");
ComboBoxCell2.Items.Add("40");
ComboBoxCell2.Items.Add("50");
ComboBoxCell2.Items.Add("60");
ComboBoxCell2.Items.Add("70");
ComboBoxCell2.Items.Add("80");
ComboBoxCell2.Items.Add("90");
ComboBoxCell2.Items.Add("100");
//ComboBoxCell.Items.AddRange(new string[] { "YES", "SOME", "NO", "N/A" });
ComboBoxCell2.FlatStyle = FlatStyle.Standard;
this.dataGridView1[11, iii] = ComboBoxCell2;
ComboBoxCell2.Dispose();
}
}
Any suggestions?
I don't know this is the right solution or not...
BUT, it fix my problem.
Here :
Right click on the .exe program (after you build) and Disable HIGH DPI
showing parameters panel the report.
I do not want show.
(source: picofile.com)
My Code is:
StiReport sr = new StiReport();
sr.Load(ClsVariable.Address + "ReportCustomerBuy.mrt");
sr.Dictionary.Variables["Ccode"].Value = txtCode.Text;
sr.Dictionary.Variables["Cname"].Value = txtName.Text;
sr.Dictionary.Variables["Ctel"].Value = txtTel.Text;
sr.Dictionary.Variables["Caddress"].Value = txtAddress.Text;
sr.Dictionary.Variables["Cfathername"].Value = txtFatherName.Text;
sr.Dictionary.Variables["Cdate"].Value = txtDate.Text;
sr.Dictionary.Variables["CPay"].Value = lblGivePrice.Text;
sr.Dictionary.Variables["CHesabK"].Value = lblPriceKK.Text;
sr.Dictionary.Variables["CBedehkar"].Value = s;
sr.Show();
Disable the request from user property
sr.Dictionary.Variables["Ccode"].RequestFromUser = false;