I have grid array and I want to print all the grid.each grid have in his cell textbox
the grid set to ShowGridLines = false;
and also I have a method the remove the textbox border.
private void DeletBorder()
{
Thickness bor = new Thickness(0.0);
for (int i = 0; i < this.gridArray.Length; i++)
{
foreach (Control ctrl in this.gridArray[i].Children)
{
if (ctrl.GetType() == typeof(TextBox))
{
((TextBox) ctrl).BorderThickness = bor;
}
}
}
}
I am trying to print all the grids in the array with this method:
private void button1_Click(object sender, RoutedEventArgs e)
{
if (this.comboBox1.SelectedIndex > -1)
{
PrintDialog printDlg = new PrintDialog();
this.DeletBorder();
if (printDlg.ShowDialog() == true)
{
this.DeletBorder();
foreach (Grid item in this.gridArray)
{
printDlg.PrintVisual(item, "Stiker Print Job");
}
}
}
else
{
MessageBox.Show("you must select the page layout first");
}
}
but the result is that only the first page printed without border/gridLines but the other still printed with border/gridLines
First issue is that, calling this.DeleteBorder()
twice is pointless.
Secondly, assuming gridArray
has only Grid
s in it; you need to not show any grid lines for each Grid.
Try this:
if (printDlg.ShowDialog() == true)
{
/* remove this--this.DeletBorder(); */
int index = 0;
foreach(Grid item in this.gridArray)
{
item.ShowGridLines = false;
// Add an identifier so you know what job is printing. You may need to call:
// item.UpdateLayout();
printDlg.PrintVisual(item, "Stiker Print Job: " + index.ToString());
}
}
If this doesn't solve your issue, please provide some XAML and/or more sample code to recreate the issue on http://gist.github.com.