Reputation: 1
I have hundreds of row in my xrTable. This table contain few column and the only i stuck here is how to get control of xrTableCell (column index 3) based from xrTableRow_BeforePrint
private void xrTableRow101_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
XRTableRow tr = new XRTableRow();
tr = (XRTableRow)sender;
////belw this should be if() for column 3 in that particular row
if (tr.Cell.[ -- get control column index 3 here ---].Text == "")
{
tr.Visible = false;
}
}
Obviously I can do many line of code for every row but all i want to do here is simplify the code to be in 1 function. So i can declare single class function to all row i want.
Upvotes: 0
Views: 3066
Reputation: 18290
Refer these:
How to loop through all rows in xrtable in XtraReport
How to loop through all rows in an XtraReport
To get an XRTable row collection, use the XRTable.Rows property instead. Please note that the FindControl method returns an XRControl object, so it is necessary to cast it to an appropriate type. For example:
XRTable table = report.FindControl("xrTable1", true) as XRTable;
foreach (XRTableRow row in table.Rows)
foreach (XRTableCell cell in row.Cells)
....
Note: You can only iterate rows which are added through designer. If your report table bind with database then it is recommend that you handle the BeforePrint event of the required XRTableCell and obtain the cell text there (using the XRTableCell.Text property or XtraReport.GetCurrentColumnValue method).
Upvotes: 1