2014-02-05 37 views
0

我設計了一個報表和地圖字段,其中包含來自數據集的表格列。現在我需要設置條件,所以我用FilterString。內部報表DetailReport,我寫了這樣的代碼:對於整個形式如何在代碼中編寫條件Filter String Winforms devexpress?

DetailReport.FilterString = "[InvoiceNumber] = " + temp;

現在我需要這個相同的代碼(FilterString),即形式Report Task左上角一些特性,因爲數據源都可以有我們添加數據集,數據成員,數據適配器然後FilterString可用。

現在我可以在Designer中添加FilterString,但我需要在代碼中添加FilterString? 我想這一個,但沒有工作 FilterString= "[InvoiceNumber] = " + temp" enter image description here

回答

1

我seggest你設置報表FilterString財產當你打電話給你XtraReport(例如:當你點擊你的表單的打印按鈕時)。下面是一個代碼示例:

private void simpleButton1_Click(object sender, EventArgs e) { 
    // Create a report instance. 
    XtraReport1 report = new XtraReport1(); 

    // Some code like setting the report datasource 

    // Specify the report's filter string. 
    report.FilterString = "[InvoiceNumber] = myValue"; 

    // Show the report's print preview. 
    pt.ShowPreviewDialog(); 
} 

此代碼從DevExpress的在線文檔文章採取:XtraReportBase.FilterString Property

+0

是的,現在它的工作很好,謝謝。直到我嘗試報告形式和事件。 – Srihari

+0

非常歡迎:-) – SidAhmed

1

一旦您設置過濾器的報告,在你需要把它做的事:

public string p = ""; 

.... 

    using (XtraReport_yourreport x = new XtraReport_yourreport()) 
      { 
       p = x.FilterString; 

      } 
+0

你好謝謝回答,對不起,我不知道在哪裏可以使用此代碼?我在BeforePrint事件中編寫了這段代碼'DetailReport.FilterString =「[InvoiceNumber] =」+ temp;',這樣當我單擊報表按鈕時,它會在報表顯示之前運行此行。 – Srihari

+0

我使用構造函數從表單中獲取唯一編號並將其存儲在不可見文本框中,並指定temp = textbox。 – Srihari