实现一个Print(PrintContent printContent)函数。
而PrintContent格式 是一个可能具有子表表单的结构class PrintFormat
{
String Caption;
int Width; //0-100
String Type; //S字符串,  L列表
}class PrintList
{
PrintFormat[] ListFormat;
object[][] Content;
}class PrintItem
{
PrintFormat ItemFormat;
Object Content; // string or PrintList
}class PrintContent
{
string Caption;
PrintItem[] PrintItems;
}希望打印出如下示例                                    入库单
入库单号: 22222222    入库日期:2006-01-23    状态: 创建
客户:×××××     入库仓库:××××   来源类型:××××
备注:×××××××入库明细产品      产品名称    条形码   产品种类   计量单位    入库数量      产品规格
产品1    ×××××   ×××   ××××   ××××    ×××××   ×××××
         库区        库位      入库数量
         库区1       ×××    ××××
         库区2       ×××    ×××
         库区3       ×××    ××××    
产品2    ×××××   ×××    ××××  ××××    ×××××   ×××××
         库区        库位      入库数量
         ××1       ×××    ××××
         ××2       ×××    ××××
大概就是这样,哪位大侠给点提示啊!! 谢谢了!

解决方案 »

  1.   


      
    报表打印控件wsReport
      

  2.   

    楼主说的是不是 按照指定的格式(PrintFormat)写文件呀?如果确定了要写文件的内容格式和文件类型,就可以当成拼串写文件处理了。
      

  3.   

    报表打印控件偶没用过呀就是按照指定的PrintContent格式读取,然后再打印,嗯,最好要先到printDocument上Preview,可行吗?
    具体怎么操作呢,偶好迷茫。。
      

  4.   

    daiming说的wsReport是不是像水晶报表那样到东东啊?
    没找到呢
    但是要求也不是那样子到,是读取一个个字段到打印页面上
    比如第一行一个标题“入库单”
    第二行获取内容“入库单号: 22222222 ”及其所占width,再获取下一个“入库日期:2006-01-23 ”及width如果本行长度不够则换行
    还有表格到列名、内容及附属子表等哪位好心人指点指点偶呀!!
      

  5.   

    如果我这样子定义PrintContentusing System;namespace Print2
    {
    /// <summary>
    /// PrintContent 的摘要说明。
    /// </summary>
    public class PrintContent
    {
    private static string m_Caption;
    private static PrintItem[] m_PrintItem; public PrintContent()
    {
    //
    // TODO: 在此处添加构造函数逻辑
    //
    } public static string Caption
    {
    get { return m_Caption; }
    set { m_Caption = value; }
    } public static PrintItem[] PrintItem
    {
    get { return m_PrintItem; }
    set { m_PrintItem = value; }
    }
    } public class PrintFormat
    {
    public PrintFormat()
    {
    }
    string Caption;
    int Width;                //整行宽设为100,获取(行宽/100×width)即为列宽
    string Type;              //S代表是字符串,L代表为列表
    } public class PrintList
    {
    public PrintList()
    {
    }
    PrintFormat[] ListFormat;
    object[][] Content;
    } public class PrintItem
    {
    public PrintItem()
    {
    }
    PrintFormat ItemFormat;
    object Content;
    }
    }那怎么在Print()里获取PrintContent各item再弄到printDocument上啊?