Occurs when a header is double-clicked.
Syntax
Event Data
The event handler receives an argument of type DoubleClickHeaderEventArgs containing data related to this event. The following DoubleClickHeaderEventArgs properties provide information specific to this event.
| Property | Description |
|---|
| Header |
Returns the header in the grid which was double clicked on.
|
Example
This snippet demonstrates how the DoubleClickHeader event can be used. In this example, when the user double-clicks on the header of the "lname" column, a comma-separated list of all the last names in that column is copied to the Windows clipboard.
For an overview of how to handle events in Visual Basic or Visual C#, see
Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see
Consuming Events in the
.NET Framework Developer's Guide.
| Visual Basic | Copy Code |
|---|
Private Sub ultraGrid1_DoubleClickHeader(sender As Object, e As Infragistics.Win.UltraWinGrid.DoubleClickHeaderEventArgs) Handles Me.ultraGrid1.DoubleClickHeader
' If the user double-clicked on the "lname" column in the "customers" band
' then copy a comma-separated list of all the last names in that column to
' the Windows clipboard.
'
If e.Header.Band.Key = "customers" And e.Header.Column.Key = "lname" Then
' If there are no rows then there is nothing to do.
'
If Me.ultraGrid1.Rows.Count = 0 Then
Return
End If
' Create a StringBuilder with roughly the initial capactity to hold all the last names.
'
Dim sb As New System.Text.StringBuilder(Me.ultraGrid1.Rows.Count * 8)
' Loop over all the rows in the first band and append each last name
' to the comma-separated list of values.
'
Dim row As UltraGridRow
For Each row In Me.ultraGrid1.Rows
sb.AppendFormat("{0}, ", row.Cells("lname").Text)
Next row
' Remove the final comma and space.
'
sb.Remove(sb.Length - 2, 2)
' Put the comma-separated list of last names on the clipboard.
'
Clipboard.SetDataObject(sb.ToString(), True)
End If
End Sub |
| C# | Copy Code |
|---|
private void ultraGrid1_DoubleClickHeader(object sender, Infragistics.Win.UltraWinGrid.DoubleClickHeaderEventArgs e)
{
// If the user double-clicked on the "lname" column in the "customers" band
// then copy a comma-separated list of all the last names in that column to
// the Windows clipboard.
//
if( e.Header.Band.Key == "customers" && e.Header.Column.Key == "lname" )
{
// If there are no rows then there is nothing to do.
//
if( this.ultraGrid1.Rows.Count == 0 )
return;
// Create a StringBuilder with roughly the initial capactity to hold all the last names.
//
System.Text.StringBuilder sb = new System.Text.StringBuilder( this.ultraGrid1.Rows.Count * 8 );
// Loop over all the rows in the first band and append each last name
// to the comma-separated list of values.
//
foreach( UltraGridRow row in this.ultraGrid1.Rows )
sb.AppendFormat( "{0}, ", row.Cells["lname"].Text );
// Remove the final comma and space.
//
sb.Remove( sb.Length - 2, 2 );
// Put the comma-separated list of last names on the clipboard.
//
Clipboard.SetDataObject( sb.ToString(), true );
}
} |
Remarks
See Also