2009-04-01 4 views
0

WinForms 응용 프로그램에서 DevExpress XtraReports를 사용하고 있지만 다른보고 도구에도 똑같이 적용 할 수 있습니다.데이터 바인딩시 현재 행에서 값 가져 오기

"행"별로 "렌더링"되어 있으므로 보고서의 행마다 일부 논리를 수행하고 싶습니다. 특히 바코드의 데이터를 사용할 수없는 경우 바코드를 숨기고 싶습니다.

private void xrBarCode2_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) 
{ 
    var barcode = (XRBarCode)sender; 

    if (barcode.Text.Trim() == "") 
    { 
     barcode.Visible = false; 
     lblWarning.Visible = true; 
    } 
    else 
    { 
     barcode.Visible = true; 
     lblWarning.Visible = false; 
    } 
} 

을하지만 그건 그냥 일반 나쁜 냄새 :

현재 나는 다음과 같은 일을 해요. 이 메서드에서 현재 데이터 행에 액세스하고 개체의 "실제"속성에 대해 작업하고 싶습니다. 그러나 그렇게 할 수는 없습니다. 다른 보고서 생성기에서이 패턴의 전형적인 패턴은 무엇입니까? 올바른 이벤트를 사용하고 있습니까? Detail_BeforePrint을 시도했지만 추가 정보가 없습니다.

과 같이 GetCurrentColumnValue와 함께

답변

4

사용 Detail_BeforePrint() :

private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { 
    if (string.IsNullOrEmpty(GetCurrentColumnValue("BarcodeColumnName"))) { 
     barcode.Visible = false; 
     lblWarning.Visible = true; 
    } else { 
     barcode.Visible = true; 
     lblWarning.Visible = false; 
    } 
}