建DataGridPrinter类
把代码全部粘贴上去
然后在WinForm中
DataGridPrinter p=new DataGridPrinter(yourDataGrid)
p.Print();

解决方案 »

  1.   

    public DataGridPrinter(DataGrid dataGrid)
    调用?
      

  2.   

    刚刚我试了一下,一开始总是报错,后来查了一下代码
    发现它用了dataGrid.TableStyles[0].GridColumnStyles.Count;
    所以我给DataGrid加了一个TableStyle,PreferredColumnWidth设置宽一点
    测试成功,预览时内容也有的.
      

  3.   

    noahart(八卦小子) 我的本来就有TableStyle,所以我就是没有出现你的那个问题
    我打印预览里只有表头,如:序号,姓名,年龄等……
    具体的内容没有出来。
      

  4.   

    我的方法是在Form上把DATAGRID放上去,然后生成出来一个DATASET最后让datagrid和dataset绑定。设置了TableStyle的属性,选了3个字段显示并让表头显示中文。
    现在的结果是程序可以运行起来,DATAGRID的内容在格子里也有。
    就是打印不出来内容。我很着急,大家帮帮忙,谢谢!
      

  5.   

    忘记说一句我的oleDbDataAdapter1是一个带条件的查询。
    是不是这样的情况在这个类里是不支持的?