バージョン

ViewStyle プロパティ (UltraTree)

コントロールの表示スタイル (列を表示するかどうか、およびどのように表示するか) を取得または設定します。
シンタックス
'宣言
 
Public Property ViewStyle As ViewStyle
public ViewStyle ViewStyle {get; set;}
使用例
Imports Infragistics.Win
Imports Infragistics.Win.Layout
Imports Infragistics.Win.UltraWinTree

    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        Dim dataTable As DataTable = Me.GetData()

        '	Set the ViewStyle property to 'Grid'
        Me.ultraTree1.ViewStyle = ViewStyle.Grid

        '	Add a column for each DataColumn in the DataTable to the RootColumnSet's
        '	Columns collection, using the DataColumn's 'ColumnName' property as the
        '	key for the corresponding UltraTreeNodeColumn.
        Dim rootColumnSet As UltraTreeColumnSet = Me.ultraTree1.ColumnSettings.RootColumnSet
        Dim dataColumn As DataColumn
        For Each dataColumn In dataTable.Columns

            Dim column As UltraTreeNodeColumn = rootColumnSet.Columns.Add(dataColumn.ColumnName)

            '	Store a reference to the underlying DataColumn in the Tag property.
            column.Tag = dataColumn

            '	Set AllowMoving to 'AllowAll', so that the end user
            '	can drag the column to a different location.
            column.AllowMoving = GridBagLayoutAllowMoving.AllowAll

            '	Set AllowSorting to True, so that the end user
            '	can sort the nodes collections associated with
            '	this column by clicking on its header.
            column.AllowSorting = DefaultableBoolean.True

            '	Set AutoSizeMode to 'VisibleNodes', so that the end user
            '	can auto-size the column by double-clicking on the right
            '	edge of its header.
            column.AutoSizeMode = ColumnAutoSizeMode.VisibleNodes

            '	Set CanShowExpansionIndicator to True for the string columns,
            '	so that cells in the column can show the expansion indicator
            '	when the ViewStyle is 'OutlookExpress'.
            If dataColumn.DataType Is GetType(String) Then
                column.CanShowExpansionIndicator = DefaultableBoolean.True
            Else
                column.CanShowExpansionIndicator = DefaultableBoolean.False
            End If

            '	Use the column's CellAppearance to change the color of
            '	the text displayed by the cells in the 'CompanyName' column.
            If column.Key = "CompanyName" Then

                column.CellAppearance.BackColor = Color.LightBlue
                column.CellAppearance.BackColor2 = Color.CornflowerBlue
                column.CellAppearance.BackGradientStyle = GradientStyle.Horizontal
                column.CellAppearance.ForeColor = Color.DarkBlue
            End If

            '	Set CellWrapText to False to prevent text from
            '	wrapping to additional lines.
            column.CellWrapText = DefaultableBoolean.False

            '	Set the DataType property to the DataType of the associated DataColumn
            column.DataType = dataColumn.DataType

            '	Use an EditorWithText embeddable editor to render the cell data
            column.Editor = New EditorWithText()

            '	Format the 'RecordID' column
            If column.Key = "RecordID" Then
                column.Format = "00000"
            End If

            '	Assign the current culture to the FormatProvider property.
            column.FormatProvider = System.Globalization.CultureInfo.CurrentCulture

            '	Set the ForeColor property of the HeaderAppearance
            column.HeaderAppearance.ForeColor = SystemColors.ControlDark

            '	Set the NullText property to "[NULL]"
            column.NullText = "[NULL]"

            '	Show sort indicators for all columns
            column.ShowSortIndicators = DefaultableBoolean.True

            '	Sort the 'CompanyName' column in ascending order
            If column.Key = "CompanyName" Then
                column.SortType = SortType.Ascending
            End If

            '	Set the Text property of the 'CompanyName' column
            If column.Key = "CompanyName" Then
                column.Text = "Company Name"
            End If

        Next

        '	Hide the 'CustomerID' column
        rootColumnSet.Columns("CustomerID").Visible = False

        '	Add a node for each DataRow in the table
        Dim row As DataRow
        For Each row In dataTable.Rows

            Dim nodeKey As String = row("CustomerID")
            Dim node As UltraTreeNode = Me.ultraTree1.Nodes.Add(nodeKey)

            For Each dataColumn In dataTable.Columns
                Dim val As Object = row(dataColumn.ColumnName)
                node.SetCellValue(rootColumnSet.Columns(dataColumn.ColumnName), val)
            Next
        Next


    End Sub

    Private Function GetData() As DataTable
        '	Create a DataTable
        Dim dataTable As DataTable = New DataTable()

        '	Add some columns
        dataTable.Columns.Add("RecordID", GetType(Integer))
        dataTable.Columns.Add("CustomerID", GetType(String))
        dataTable.Columns.Add("CompanyName", GetType(String))
        dataTable.Columns.Add("ContactName", GetType(String))
        dataTable.Columns.Add("ContactTitle", GetType(String))

        '	Add some rows
        dataTable.Rows.Add(New Object() {1652, "ALFKI", "Alfreds Futterkiste", "Maria Anders", "Sales Representative"})
        dataTable.Rows.Add(New Object() {1346, "ANATR", "Ana Trujillo Emparedados y helados", "Ana Trujillo", "Owner"})
        dataTable.Rows.Add(New Object() {127, "ANTON", "Antonio Moreno Taquería", "Antonio Moreno", "Owner"})
        dataTable.Rows.Add(New Object() {4460, "AROUT", "Around the Horn", "Thomas Hardy", "Sales Representative"})
        dataTable.Rows.Add(New Object() {166, "BERGS", "Berglunds snabbköp", "Christina Berglund", "Order Administrator"})

        Return dataTable
    End Function
using Infragistics.Win;
using Infragistics.Win.Layout;
using Infragistics.Win.UltraWinTree;
using System.Diagnostics;

		private void button1_Click(object sender, System.EventArgs e)
		{
			DataTable dataTable = this.GetData();

			//	Set the ViewStyle property to 'Grid'
			this.ultraTree1.ViewStyle = ViewStyle.Grid;

			//	Add a column for each DataColumn in the DataTable to the RootColumnSet's
			//	Columns collection, using the DataColumn's 'ColumnName' property as the
			//	key for the corresponding UltraTreeNodeColumn.
			UltraTreeColumnSet rootColumnSet = this.ultraTree1.ColumnSettings.RootColumnSet;
			foreach( DataColumn dataColumn in dataTable.Columns )
			{
				UltraTreeNodeColumn column = rootColumnSet.Columns.Add( dataColumn.ColumnName );

				//	Store a reference to the underlying DataColumn in the Tag property.
				column.Tag = dataColumn;

				//	Set AllowMoving to 'AllowAll', so that the end user
				//	can drag the column to a different location.
				column.AllowMoving = GridBagLayoutAllowMoving.AllowAll;

				//	Set AllowSorting to True, so that the end user
				//	can sort the nodes collections associated with
				//	this column by clicking on its header.
				column.AllowSorting = DefaultableBoolean.True;

				//	Set AutoSizeMode to 'VisibleNodes', so that the end user
				//	can auto-size the column by double-clicking on the right
				//	edge of its header.
				column.AutoSizeMode = ColumnAutoSizeMode.VisibleNodes;

				//	Set CanShowExpansionIndicator to True for the string columns,
				//	so that cells in the column can show the expansion indicator
				//	when the ViewStyle is 'OutlookExpress'.
				if ( dataColumn.DataType == typeof(string) )
					column.CanShowExpansionIndicator = DefaultableBoolean.True;
				else
					column.CanShowExpansionIndicator = DefaultableBoolean.False;

				//	Use the column's CellAppearance to change the color of
				//	the text displayed by the cells in the 'CompanyName' column.
				if ( column.Key == "CompanyName" )
				{
					column.CellAppearance.BackColor = Color.LightBlue;
					column.CellAppearance.BackColor2 = Color.CornflowerBlue;
					column.CellAppearance.BackGradientStyle = GradientStyle.Horizontal;
					column.CellAppearance.ForeColor = Color.DarkBlue;
				}

				//	Set CellWrapText to False to prevent text from
				//	wrapping to additional lines.
				column.CellWrapText = DefaultableBoolean.False;

				//	Set the DataType property to the DataType of the associated DataColumn
				column.DataType = dataColumn.DataType;

				//	Use an EditorWithText embeddable editor to render the cell data
				column.Editor = new EditorWithText();

				//	Format the 'RecordID' column
				if ( column.Key == "RecordID" )
					column.Format = "00000";

				//	Assign the current culture to the FormatProvider property.
				column.FormatProvider = System.Globalization.CultureInfo.CurrentCulture;

				//	Set the ForeColor property of the HeaderAppearance
				column.HeaderAppearance.ForeColor = SystemColors.ControlDark;

				//	Set the NullText property to "[NULL]"
				column.NullText = "[NULL]";

				//	Show sort indicators for all columns
				column.ShowSortIndicators = DefaultableBoolean.True;

				//	Sort the 'CompanyName' column in ascending order
				if ( column.Key == "CompanyName" )
					column.SortType = SortType.Ascending;

				//	Set the Text property of the 'CompanyName' column
				if ( column.Key == "CompanyName" )
					column.Text = "Company Name";
				
			}

			//	Hide the 'CustomerID' column
			rootColumnSet.Columns["CustomerID"].Visible = false;

			//	Add a node for each DataRow in the table
			foreach( DataRow row in dataTable.Rows )
			{
				string nodeKey = row["CustomerID"] as string;
				UltraTreeNode node = this.ultraTree1.Nodes.Add( nodeKey );

				foreach( DataColumn dataColumn in dataTable.Columns )
				{
					object val = row[dataColumn.ColumnName];
					node.SetCellValue( rootColumnSet.Columns[dataColumn.ColumnName], val );
				}
			}

		}

		private DataTable GetData()
		{
			//	Create a DataTable
			DataTable dataTable = new DataTable();

			//	Add some columns
			dataTable.Columns.Add( "RecordID", typeof(int) );
			dataTable.Columns.Add( "CustomerID", typeof(string) );
			dataTable.Columns.Add( "CompanyName", typeof(string) );
			dataTable.Columns.Add( "ContactName", typeof(string) );
			dataTable.Columns.Add( "ContactTitle", typeof(string) );

			//	Add some rows
			dataTable.Rows.Add( new object[]{ 1652, "ALFKI", "Alfreds Futterkiste", "Maria Anders", "Sales Representative" } );
			dataTable.Rows.Add( new object[]{ 1346, "ANATR", "Ana Trujillo Emparedados y helados", "Ana Trujillo", "Owner" } );
			dataTable.Rows.Add( new object[]{ 127, "ANTON", "Antonio Moreno Taquería", "Antonio Moreno", "Owner" } );
			dataTable.Rows.Add( new object[]{ 4460, "AROUT", "Around the Horn", "Thomas Hardy", "Sales Representative" } );
			dataTable.Rows.Add( new object[]{ 166, "BERGS", "Berglunds snabbköp", "Christina Berglund", "Order Administrator" } );

			return dataTable;
		}
参照