BoldDeskPremium customer service software with affordable pricing: $10 for 3 agents. Try it for free.
private void button1_Click(object sender, EventArgs e)
{
PrintDialog printDialog = new PrintDialog();
if (printDialog.ShowDialog() != DialogResult.OK)
{
return;
}
GridPrintDocument printDocument = new GridPrintDocument(this.gridControl1);
printDocument.PrinterSettings = printDialog.PrinterSettings;
bool hideRow = false;
if (!this.gridControl1.Properties.PrintColHeader)
{
this.gridControl1.Properties.PrintColHeader = true;
this.gridControl1.QueryRowHeight += new GridRowColSizeEventHandler(gridControl1_QueryRowHeight);
hideRow = true;
}
printDocument.Print();
if (hideRow)
{
this.gridControl1.Properties.PrintColHeader = false;
this.gridControl1.QueryRowHeight += new GridRowColSizeEventHandler(gridControl1_QueryRowHeight);
hideRow = false;
}
}
void gridControl1_QueryRowHeight(object sender, GridRowColSizeEventArgs e)
{
if (gridControl1.PrintingMode && e.Index == 0)
{
e.Size = 0;
e.Handled = true;
}
}
this.gridControl1.QueryRowHeight += new GridRowColSizeEventHandler(gridControl1_QueryRowHeight);
this.gridControl1.QueryRowHeight -= new GridRowColSizeEventHandler(gridControl1_QueryRowHeight);