xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xtrareportbase-dot-getcurrentcolumnvalue-1-x28-system-dot-string-x29.md
Returns the current value (strongly typed) of the specified column (field) from a collection assigned to a report’s Data Member property. If the property is not specified, the method returns the current value from a root collection of the report’s Data Source.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
public T GetCurrentColumnValue<T>(
string columnName
)
Public Function GetCurrentColumnValue(Of T)(
columnName As String
) As T
| Name | Type | Description |
|---|---|---|
| columnName | String |
A column (field) name.
|
| Name | Description |
|---|---|
| T |
A value type.
|
| Type | Description |
|---|---|
| T |
The current column (field) value. If the specified column (field) was not found, the method returns null.
|
Call the GetCurrentColumnValue method in control event handlers (for example, in a BeforePrint handler).
private void xrLabel1_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e) {
var currValue = GetCurrentColumnValue<string>("CategoryName");
}
Private Sub xrLabel1_BeforePrint(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles xrLabel1.BeforePrint
Dim currValue = GetCurrentColumnValue(Of String)("CategoryName")
End Sub
Business objects (such as Object Data Source, EF Data Source, or XPO Data Source) might contain methods or properties with custom logic. To get the current value from such methods or properties, use the GetCurrentRow method. Call this method to obtain a business object, then get a value from the object’s method or property.
To get the current column (field) value from a collection assigned to a detail report’s Data Member (Data Source) property, call the detail report’s GetCurrentColumnValue method in control event handlers (for example, in a BeforePrint handler).
private DevExpress.XtraReports.UI.DetailReportBand DetailReport1;
private void xrLabel2_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e) {
var currValue = DetailReport1.GetCurrentColumnValue<string>("ProductName");
}
Private DetailReport1 As DevExpress.XtraReports.UI.DetailReportBand
Private Sub xrLabel2_BeforePrint(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles xrLabel2.BeforePrint
Dim currValue = DetailReport1.GetCurrentColumnValue(Of String)("ProductName")
End Sub
You can also use a control’s Report property to access the report to which the control belongs. This property can be useful if your report consists of multiple nested detail reports, and you want to access a control’s detail report in a control event handler.
using DevExpress.XtraReports.UI;
// ...
private void xrLabel3_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e) {
var label = sender as XRLabel;
var currValue = label.Report.GetCurrentColumnValue<string>("ProductName");
}
Imports DevExpress.XtraReports.UI
' ...
Private Sub xrLabel3_BeforePrint(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles xrLabel3.BeforePrint
Dim label = TryCast(sender, XRLabel)
Dim currValue = label.Report.GetCurrentColumnValue(Of String)("ProductName")
End Sub
See Also