Johan Lee
Johan Lee

Reputation: 29

Easiest way to print Datagrid

Trying to print a datagrid in silverlight triggered by a button Any solutions?

Upvotes: 0

Views: 292

Answers (2)

arvind
arvind

Reputation: 1493

referring to this article Printing in silverlight

Use System.Windows.Printing.PrintDocument There are three events to handles printing. They are

  • EndPrint
  • StartPrint
  • PrintPage

use Print() to do the print operation set the DocumentName property for the name.

  • Create instance of PrintDocument class
  • Specify the content to print.
  • Write code to handle the PagePrint event

    private void mybutton_Click(object sender, RoutedEventArgs e) { PrintDocument prt = new PrintDocument(); prt.PrintPage +=(s,args) => { args.PageVisual = txtBlcok; }; prt.Print(); }

Upvotes: 0

Related Questions