Version

InitializeColumn Event

Occurs when a grid column is initialized.
Syntax
'Declaration
 
Public Event InitializeColumn As InitializeColumnEventHandler
public event InitializeColumnEventHandler InitializeColumn
Event Data

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

PropertyDescription
Column Ultra grid column.
ExcelFormatStr Excel specific format string.
FrameworkFormatStr Format string used in .NET Framework.
Remarks

The FrameworkFormatStr argument has value only if column has format string assigned. Value represents format string in .NET Framework format.

If needed, the ExcelFormatStr argument should be set to excel specific format string. If not set, cells in column will have no specific format.

This event is fired when a grid column is initialized. You should use this event to convert format strings from .NET Framework format to Excel format. See .NET Framework documentation and Excel help file for more information about differences in format strings.

Example
Following code uses InitializeColumn event to convert .NET specific format strings to Excel specific format strings. Two of the format strings are "manually" converted and all other formats are just copied (be careful with copying as some more complex format strings can cause Microsoft Excel to throw an error if not converted properly).

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.

Private Sub MyGridExporter_InitializeColumn(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.ExcelExport.InitializeColumnEventArgs) Handles MyGridExporter.InitializeColumn
    Select Case e.FrameworkFormatStr
        Case "##.##"
            e.ExcelFormatStr = "[<>0]##.##;[=0]\" \ ";"

        Case "hh:mm:ss"
            e.ExcelFormatStr = "m.d.yy h:mm;@"

        Case Else
            e.ExcelFormatStr = e.FrameworkFormatStr
    End Select
End Sub
private void InitializeColumn_EH(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.InitializeColumnEventArgs e)
{
	switch(e.FrameworkFormatStr)
	{
		case "##.##":
			e.ExcelFormatStr = "[<>0]##.##;[=0]\"\";";
			break;

		case "hh:mm:ss":
			e.ExcelFormatStr = "m.d.yy h:mm;@";
			break;

		default:
			e.ExcelFormatStr = e.FrameworkFormatStr;
			break;
	}
}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, 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