在DELPHI中 有 控件  COMBOBOX1
如何见将COMBOBOX1.TXT的值传递到 FAST REPORT3.07中自定义的变量(目录为POS 变量名为GUARD)??

解决方案 »

  1.   

    好象是:
    frVariants['Guard'] := comboBox1.text;
      

  2.   

    提示错误!!
    ”comboBox1.text的值“ID 未定义??
      

  3.   

    http://blog.csdn.net/jinzhili/archive/2005/10/12/500263.aspx
      

  4.   

    frReport1.Dictionary.Variables['Guard]:=comboBox1.text;
      

  5.   

    quicksand201(流沙) :
    frReport1.Dictionary.Variables['Guard]:=comboBox1.text;
    这不知道 是 不是跟以下两句一样?
    frxreport1.variables.variables['guard']:=combobox1.text;
    frxreport1.variables.item[0].value:=Combobox1.text
    谢谢
      

  6.   

    rxreport1.variables.variables['guard']:=combobox1.text;
    frxreport1.variables.item[0].value:=Combobox1.text
    报表运行是是集成到程序中的 在报表设计中加入变量[GUARD],程序运行的时候会出错!!
      

  7.   

    是一样的,错了可别打我:)
    至于出错的原因,可能是"FastReport把你赋给变量的值当作了一个需要解析和计算的表达式。你可以加一个引号上去"
    希望下面的资料可以帮到你---------------- 使用变量 ------------------------------------- 问:怎样在程序中给数据字典的变量列表赋值? 
    答:数据字典中的所有分类和变量都可以用TfrReport.Dictionary.Variables来访问存取。 with frReport1.Dictionary do 
    begin 
    // creating category (space in category name required!) 
    Variables[' New category'] := ''; 
    // creating variables 
    Variables['New Variable'] := 'CustomerData.Customers."CustNo"'; 
    Variables['Another Variable'] := 'Page#'; 
    end; 问:我自定义了一个变量并赋了一个字符串值给它, with frReport1.Dictionary do 
    Variables['Month'] := 'March'; 但当我运行报表时却出错,为什么? 
    答:因为FastReport把你赋给变量的值当作了一个需要解析和计算的表达式。你可以加一个引号上去: with frReport1.Dictionary do 
    Variables['Month'] := '''' + 'March' + ''''; 或者,用frVariables来传递静态的值给报表。 问:有什么办法可以不要把所有的数据集都显示在数据字典中? 
    答:用TfrReport.Dictionary.DisabledDatasets: with frReport1.Dictionary do 
    begin 
    // turn of this dataset 
    DisabledDatasets.Add('CustomerData.Bio'); 
    // or, turn off entire datamodule/form 
    DisabledDatasets.Add('CustomerData*'); 
    end; 
    问:怎样传递数据给报表? 
    答:有几种方法都可以实现,第一个方法是使用全局对象frVariables(定义在FR_Class单元中的) frVariables['My variable'] := 10; 这行代码用My variable作为名字创建一个新变量并赋值为10。 
    这是传递静态数据给报表的最好方法。 第二个方法是用TfrReport.OnGetValue事件。可以用这个方法来传递动态数据,比如值随着记 
    录的不同而改变的数据。 procedure TForm1.frReport1GetValue(ParName: String; var ParValue: Variant); 
    begin 
    if ParName = 'MyField' then 
    ParValue := Table1MyField.Value; 
    end; 最后,第三种方法是用代码在数据字典中定义变量(可参考上面的问题): with frReport1.Dictionary do 
    begin 
    Variables['MyVariable'] := 'CustomerData.Customers."CustNo"'; 
    Variables['Another Variable'] := '10'; 
    end; 
    问:可以从报表中传递数据给程序吗? 
    答:用frVariables对象,如果在报表中任意一个对象的脚本里有写下面的代码: MyVariable := 10 在程序中可以用如下的代码来获取MyVariable变量的值: 
    v := frVariables['MyVariable'];