0

XtraReport の行 (クリックされた場所) からすべての値を取得しようとしました。
理由はわかりませんが、xrTableRow1_PreviewClick と xrTable1_PreviewClick が機能しません。
xrTableCell4_PreviewClick のみで機能します。そして、「e.Brick.Text」を通じて、セル内の値のみを取得できます。

private void xrTableCell1_PreviewClick(object sender, PreviewMouseEventArgs e)
{
  var tmp = e.Brick.Text;
}

私が試してみると:

GetCurrentRow()

最初の行のみを提供します。それは私が必要とするものではありません。)

クリックされた行からすべての値を取得するにはどうすればよいですか? または、クリックした行インデックスを取得するにはどうすればよいですか?
私のレポートはデザイナーで次のようになります。
ここに画像の説明を入力

前もって感謝します!

4

2 に答える 2

5

There is no simple way to access the corresponding data row using brick methods. When all the required bricks are generated, the report does not refer to a data source anymore. In other words, bricks do now know about the underlying data. They just contain a text, image, or other controls.

The simplest way to accomplish this task is to handle the XRControl's BeforePrint event and pass the corresponding data object (DataRowView or a custom object) to the XRControl's Tag property:

private void xrLabel_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
    // Obtain the current label.
    XRLabel label = (XRLabel)sender;

    //Obtain the parent Report
    XtraReportBase parentReport = label.Report;

    //Get the data object
    object currentData = parentReport.GetCurrentRow();

    //Pass this object to Tag
    label.Tag = currentData;
}

After that, it's possible to access the data object via the e.Brick.Value property in the PreviewClick event handler.

于 2013-11-14T09:49:12.577 に答える
1

プレビュー モードで詳細バンクの任意のフィールドの値をキャプチャする VB.net コード。

Dim myo As Object
dim myacct as long

For i = 0 To e.Brick.Parent.Bricks.Count
Try
    myo = e.Brick.Parent.Bricks.Item(i) ' cant get name w/o this ???
    If myo.brickowner.name = "XrLabel14" Then  ' test for desired label
        myacct = myo.text   'capture the value
         Exit For
    End If
 Catch oerr As Exception
    'log error here
 End Try

Next
于 2015-03-19T20:10:32.550 に答える