Search code examples
c#winformsdevexpressxtrareport

How to bind a multiple rows from access table by query in runtime using XtraReport Winforms?


How to bind a multiple rows to report in label or table ?? If my table is single row I can easily bind and it display in label and also display in table but my table consist of 2 or 3 rows it wont display. How to show multiple row in a report ? I need o filter it according to which item is selected ??


Solution

  • Don't bind it directly. Use BeforePrint event for that label (not for the report!)

    private void xrLabel4_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
      var id = this.GetCurrentColumnValue<int>("ID"); // get value of field ID for this row
      var lines = GetRows(id); // for demo only: returns string[]
      (sender as XRLabel).Lines = lines;
    }
    

    Don't forget to set property Multiline to true.