Gets/sets the string that is displayed by cells whose value is null.
Syntax
| Visual Basic (Declaration) | |
|---|
Public Property NullText As String |
| C# | |
|---|
public string NullText {get; set;} |
Remarks
Example
The following code sample demonstrates how to populate the UltraListView control's SubitemColumns collection from the 'Orders' table of the Northwind database:
| Visual Basic | Copy Code |
|---|
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinListView
Private Sub PopulateSubItemColumnsCollection(ByVal ordersTable As DataTable, ByVal employeesValueList As ValueList, ByVal shippersValueList As ValueList)
Dim dataRow As DataRow
Dim mainDataColumn As DataColumn = ordersTable.Columns("OrderID")
Me.ultraListView1.MainColumn.Text = mainDataColumn.Caption
Me.ultraListView1.MainColumn.DataType = mainDataColumn.DataType
Dim dataColumn As DataColumn
For Each dataColumn In ordersTable.Columns
If dataColumn Is mainDataColumn Then GoTo skip
Dim subItemColumn As UltraListViewSubItemColumn = Me.ultraListView1.SubItemColumns.Add(dataColumn.ColumnName)
subItemColumn.Text = dataColumn.Caption
subItemColumn.DataType = dataColumn.DataType
If subItemColumn.Key = "CustomerID" Or _
subItemColumn.Key = "ShipName" Or _
subItemColumn.Key = "ShipAddress" Or _
subItemColumn.Key = "ShipCity" Or _
subItemColumn.Key = "ShipRegion" Or _
subItemColumn.Key = "ShipPostalCode" Or _
subItemColumn.Key = "ShipCountry" Then
subItemColumn.VisibleInDetailsView = DefaultableBoolean.False
subItemColumn.VisibleInTilesView = DefaultableBoolean.False
End If
If subItemColumn.Key = "EmployeeID" Then subItemColumn.ValueList = employeesValueList
If subItemColumn.Key = "ShipVia" Then subItemColumn.ValueList = shippersValueList
subItemColumn.AllowMoving = DefaultableBoolean.True
subItemColumn.AllowSizing = DefaultableBoolean.True
subItemColumn.AllowSorting = DefaultableBoolean.True
subItemColumn.FormatProvider = Nothing
If subItemColumn.DataType Is GetType(System.DateTime) Then
subItemColumn.Format = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern
subItemColumn.NullText = "(No Date Set)"
ElseIf subItemColumn.DataType Is GetType(System.Decimal) Then
subItemColumn.Format = "$#,###,###.00"
subItemColumn.FormatProvider = System.Globalization.CultureInfo.CreateSpecificCulture("en-US")
subItemColumn.NullText = "(No Amount Set)"
subItemColumn.SubItemAppearance.TextHAlign = HAlign.Right
subItemColumn.SubItemAppearance.ForeColor = Color.Green
End If
subItemColumn.Tag = dataColumn
skip:
Next
End Sub |
| C# | Copy Code |
|---|
using Infragistics.Win; using Infragistics.Win.UltraWinListView; using System.Diagnostics;
private void PopulateSubItemColumnsCollection( DataTable ordersTable, ValueList employeesValueList, ValueList shippersValueList )
{
// Use the UltraListView's MainColumn to
represent the 'OrderID' column
// of the 'Orders' table.
DataColumn mainDataColumn =
ordersTable.Columns["OrderID"];
this.ultraListView1.MainColumn.Text =
mainDataColumn.Caption;
this.ultraListView1.MainColumn.DataType
= mainDataColumn.DataType;
// Populate the SubItemColumns collection from
the Columns collection of the
// 'Orders' table
foreach( DataColumn dataColumn
in ordersTable.Columns )
{
if ( dataColumn
== mainDataColumn )
continue;
// Add an
UltraListViewSubItemColumn to the UltraListView's SubItemColumns collection,
// using the
DataColumn's ColumnName for the Key.
UltraListViewSubItemColumn subItemColumn
= this.ultraListView1.SubItemColumns.Add( dataColumn.ColumnName );
// Set the
UltraListViewSubItemColumn's Text property to the DataColumn's Caption.
subItemColumn.Text =
dataColumn.Caption;
// Set the
UltraListViewSubItemColumn's DataType property to the DataColumn's DataType.
subItemColumn.DataType =
dataColumn.DataType;
// Hide the columns that
the end user does not need to see.
if (
subItemColumn.Key == "CustomerID" ||
subItemColumn.Key ==
"ShipName" ||
subItemColumn.Key ==
"ShipAddress" ||
subItemColumn.Key ==
"ShipCity" ||
subItemColumn.Key ==
"ShipRegion" ||
subItemColumn.Key ==
"ShipPostalCode" ||
subItemColumn.Key ==
"ShipCountry" )
{
subItemColumn.VisibleInDetailsView =
DefaultableBoolean.False;
subItemColumn.VisibleInTilesView =
DefaultableBoolean.False;
}
// Assign the employees
ValueList to the 'EmployeeID' column.
if (
subItemColumn.Key == "EmployeeID" )
subItemColumn.ValueList =
employeesValueList;
// Assign the shippers
ValueList to the 'ShipVia' column.
if (
subItemColumn.Key == "ShipVia" )
subItemColumn.ValueList =
shippersValueList;
// Allow the
UltraListViewSubItemColumn to be moved
subItemColumn.AllowMoving =
DefaultableBoolean.True;
// Allow the
UltraListViewSubItemColumn to be resized
subItemColumn.AllowSizing =
DefaultableBoolean.True;
// Allow the
UltraListViewSubItemColumn to be sorted
subItemColumn.AllowSorting =
DefaultableBoolean.True;
// Set the
FormatProvider to null so that the current culture is used.
subItemColumn.FormatProvider =
null;
// Set some
UltraListViewSubItemColumn properties based the data type
if (
subItemColumn.DataType == typeof(System.DateTime) )
{
//
Use the current culture's ShortDatePattern to format dates
subItemColumn.Format = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
//
Customize the NullText for this data type.
subItemColumn.NullText = "(No Date Set)";
}
else
if (
subItemColumn.DataType == typeof(System.Decimal) )
{
//
Since the currency values are expressed in US dollars, assign
//
a currency format that is appropriate for that currency system,
//
and assign 'English - United States' to the FormatProvider property.
subItemColumn.Format = "$#,###,###.00";
subItemColumn.FormatProvider =
System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
//
Customize the NullText for this data type.
subItemColumn.NullText = "(No Amount Set)";
//
Right-align the text for this column
subItemColumn.SubItemAppearance.TextHAlign = HAlign.Right;
//
Use the SubItemAppearance's ForeColor property to customize the
//
color of text for this column.
subItemColumn.SubItemAppearance.ForeColor = Color.Green;
}
// Assign a reference to
the DataColumn to the UltraListViewSubItemColumn's
// Tag property.
subItemColumn.Tag = dataColumn;
}
} |
See Also