Xceed Grid for WinForms v4.3 Documentation
QueryVariableText Event


Xceed.Grid.Reporting.v4.3 Assembly > Xceed.Grid.Reporting Namespace > Report Class : QueryVariableText Event
Raised when a variable is encountered to allow for the final value of the variable to modified before it is printed, and/or to handle custom variables.
Syntax
'Declaration
 
Public Event QueryVariableText As QueryVariableTextEventHandler
'Usage
 
Dim instance As Report
Dim handler As QueryVariableTextEventHandler
 
AddHandler instance.QueryVariableText, handler
public event QueryVariableTextEventHandler QueryVariableText
Event Data

The event handler receives an argument of type QueryVariableTextEventArgs containing data related to this event. The following QueryVariableTextEventArgs properties provide information specific to this event.

PropertyDescription
Gets the value of the variable's "format" parameter.  
Gets the Format Provider that will be used to format the string representation of the variable.  
Gets the current page number.  
Gets the total number of pages in the report.  
Gets the name of the variable.  
Gets or sets the string representation of the variable.  
Remarks
The following example demonstrates how to use custom variables ("EvenPage" and "OddPage") to provide custom formatted strings.

If String.Compare(e.VariableName, "EvenPage", True, System.Globalization.CultureInfo.InvariantCulture) = 0 Then
  If e.PageNumber Mod 2 = 0 Then
    Dim formatProvider As IFormatProvider = e.FormatProvider
    Dim format As String = e.Format
    
    If formatProvider Is Nothing Then
      formatProvider = System.Globalization.CultureInfo.CurrentCulture.NumberFormat
    End If
    
    If format.Length = 0 Then
      format = "g"
    End If
    
    e.VariableText = String.Format(formatProvider, "{0:" + format + "}", e.PageNumber)
  End If
Else
  If String.Compare(e.VariableName, "OddPage", True) = 0 Then
    If e.PageNumber Mod 2 = 1 Then
      Dim formatProvider As IFormatProvider = e.FormatProvider
      Dim format As String = e.Format
      
      If formatProvider Is Nothing Then
        formatProvider = System.Globalization.CultureInfo.CurrentCulture.NumberFormat
      End If
      
      If format.Length = 0 Then
        format = "g"
      End If
      
      e.VariableText = String.Format(formatProvider, "{0:" + format + "}", e.PageNumber)
    End If
  End If
End If

if( string.Compare( e.VariableName, "EvenPage", true, System.Globalization.CultureInfo.InvariantCulture ) == 0 )
{
  if( e.PageNumber  2 == 0 )
  {
    IFormatProvider formatProvider = e.FormatProvider;
    string format = e.Format;
    if( formatProvider == null )
      formatProvider = System.Globalization.CultureInfo.CurrentCulture.NumberFormat;
    if( format.Length == 0 )
      format = "g";
    e.VariableText = string.Format( formatProvider, "{0 2 == 1 )
  {
    IFormatProvider formatProvider = e.FormatProvider;
    string format = e.Format;
    if( formatProvider == null )
      formatProvider = System.Globalization.CultureInfo.CurrentCulture.NumberFormat;
    if( format.Length == 0 )
      format = "g";
    e.VariableText = string.Format( formatProvider, "{0:" + format + "}", e.PageNumber );
  }
}    

The DATETIME variable will only be evaluated once at the beginning. All other variables will be evaulated for each page.

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also