tags:

views:

191

answers:

1

Hi,

I have a datatable as

  DataTable dt = new DataTable( "Table1" );
  dt.Columns.Add( "c1" );
  dt.Columns.Add( "c2" );
  dt.Columns.Add( "c3" );
  DataRow dr = dt.NewRow();
  dr["c1"] = "100";
  dr["c2"] = "100";
  dr["c3"] = "100";
  dt.Rows.Add( dr );
  dt.AcceptChanges();
  printListView.DataContext = dt;

I have also a listview for showing the table.

ListView                                    
                  HorizontalAlignment="Stretch" 
                  HorizontalContentAlignment="Stretch" 
                  SelectionMode="Single" 
                  ItemsSource="{Binding}" 
                  Name="printListView" 
                  Margin="10"
                  ListView.View
                        GridView
                              GridViewColumn Header="c1" DisplayMemberBinding="{Binding c1}"/
                              GridViewColumn Header="c2" DisplayMemberBinding="{Binding c2}"/
                              GridViewColumn Header="c3" DisplayMemberBinding="{Binding c3}"/
                        /GridView
                  /ListView.View
            /ListView

How can I print this table?

Thanks

+1  A: 

One way would be to bind the table to a listview and then make a document out of it and print it.

bitbonk