バージョン

Appearance プロパティ (UltraDateTimeEditor)

Infragistics.Win.AppearanceBase オブジェクトのフォーマッティングを制御する オブジェクトを返すか設定します。
シンタックス
'宣言
 
Public Property Appearance As Infragistics.Win.AppearanceBase
public Infragistics.Win.AppearanceBase Appearance {get; set;}
解説

オブジェクトの Appearance プロパティを使用して、外観を決定する Appearance オブジェクトにオブジェクトを関連付けます。Appearanceオブジェクトには、色、境界線、フォント、透明度などの設定を制御するプロパティがあります。UltraWinScheduleのオブジェクトでは、ほとんどの場合、書式関連のプロパティを直接設定しません。その代わりに Appearance オブジェクトのプロパティを設定することで、その Appearance オブジェクトが関連付けられているオブジェクトの書式設定を制御します。

Appearance プロパティを使用してSSAppearance オブジェクトの属性を他のオブジェクトに割り当てるには、2 つの方法があります。1つは、新しい Appearance オブジェクトを作成し、それを Appearances コレクションに直接追加します。これで新しい Appearance オブジェクトを、書式設定したいオブジェクトの Appearance プロパティに割り当てます。この方法では、事前に明示的に作成してプロパティの設定を割り当てなければならない「名前付き」Appearance オブジェクトを使用します。たとえば、コントロールの Appearances コレクション内にオブジェクトを作成して値を割り当てるには、次のように記述します。

UltraDateTimeEditor1.Appearances.Add "New1"

UltraDateTimeEditor1.Appearances("New1").BorderColor = Color.Blue

UltraDateTimeEditor1.Appearances("New1").ForeColor = Color.Red

この方法でオブジェクトを作成すると、コントロールの表示部分に書式は適用されません。オブジェクトはプロパティ値が設定された状態でコレクション内に存在するだけであり、使用されるまで待機しています。実際にこのオブジェクトを使用するには、コントロール (または別のオブジェクト) の Appearance プロパティにそのオブジェクトを割り当てる必要があります。

UltraDateTimeEditor1.Appearance = UltraDateTimeEditor1.Appearances("New1")

この場合、存在している Appearance オブジェクトは 1 つだけです。コントロールの外観は、コレクション内の「New1」オブジェクトの設定によって決まります。コレクション内のオブジェクトに変更を加えると、その変更は即時にコントロールに反映されます。

Appearanceプロパティのもう 1 つの使用方法は、Appearanceプロパティに直接プロパティ値を設定する方法です。次に例を示します。

UltraDateTimeEditor1.Appearance.ForeColor = Color.Blue

この場合は、コントロールによって自動的に Appearance オブジェクトが作成されます。この Appearance オブジェクトは Appearances コレクションのメンバーではなく、名前はありません。このオブジェクトは、作成対象のオブジェクトに固有の「組み込み」Appearanceオブジェクトです。組み込み Appearance オブジェクトのプロパティを変更すると、それが属するオブジェクト内でのみ、その変更が反映されます。

従属関係を作成せずに、名前付き Appearance オブジェクトのプロパティを組み込み Appearance オブジェクトに割り当てることができます。たとえば、次のようなコードがあるとします。

UltraDateTimeEditor1.Appearance.ForeColor = UltraDateTimeEditor1.Appearances("New1").ForeColor

この例では、組み込みオブジェクトの前景色と名前付きオブジェクトの前景色の間に関係は 確立されません 。これは単に名前付きオブジェクトの値を組み込みオブジェクトの値に1回限りで割り当てているだけです。この場合は 2 つの Appearance オブジェクトが存在し、1 つはコレクション内にあり、もう 1 つはコントロールに関連付けられ、互いに独立して動作します。

従属関係を作成せずに名前付きオブジェクトのすべてのプロパティを組み込みオブジェクトに一度に割り当てる場合、Appearance オブジェクトの Clone メソッドを使用して設定を複製し、それを適用することができます。名前付き Appearance オブジェクト「New1」のすべてのプロパティ設定をコントロールの組み込み Appearance オブジェクトに適用する場合に、「New1」への変更をコントロールに自動的に反映したくないときは、次のコードを使用します。

UltraDateTimeEditor1.Appearance = UltraDateTimeEditor1.Appearances("New1").Clone

Appearance オブジェクトのプロパティは、階層式に適用することも可能です。プロパティの中には「use default」値に設定できるものがあります。 これは、オブジェクトの親からプロパティの設定を取得することを意味します。この機能はデフォルトで有効になっているため、設定を変更しないかぎり、子オブジェクトは親に類似し、コントロールの上位階層で設定された書式は下位のオブジェクトに引き継がれます。

使用例
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinEditors

    Private Sub SetupAppearance()
        '	Create a new Appearance object
        Dim appearance As Infragistics.Win.Appearance = New Infragistics.Win.Appearance()

        '	Set some of the color properties of the Appearance object
        appearance.BackColor = Color.White
        appearance.BackColor2 = Color.LightBlue
        appearance.ForeColor = Color.DarkBlue

        '	Set the background gradient style
        appearance.BackGradientStyle = GradientStyle.ForwardDiagonal

        '	Set the AlwaysInEditMode property to false so gradient drawing
        '	will be enabled when the control does not have the input focus
        '
        '	Note that this only applies to the controls that use a TextBox for
        '	their edit portion (UltraTextEditor, UltraComboEditor, and UltraFontNameEditor)
        Me.ultraTextEditor1.AlwaysInEditMode = False
        Me.ultraComboEditor1.AlwaysInEditMode = False
        Me.ultraFontNameEditor1.AlwaysInEditMode = False

        '	Set each UltraWinEditor control's Appearance property to the
        '	Appearance object we just created, so they all have the same
        '	appearance
        Me.ultraTextEditor1.Appearance = appearance
        Me.ultraComboEditor1.Appearance = appearance
        Me.ultraFontNameEditor1.Appearance = appearance
        Me.ultraDateTimeEditor1.Appearance = appearance
        Me.ultraNumericEditor1.Appearance = appearance
        Me.ultraCurrencyEditor1.Appearance = appearance

        '	Create another Appearance object that we will assign to the
        '	ButtonAppearance property of the relevant controls
        Dim buttonAppearance As Infragistics.Win.Appearance = New Infragistics.Win.Appearance()
        buttonAppearance.BackColor = Color.AliceBlue
        buttonAppearance.BackColorDisabled = Color.AliceBlue
        buttonAppearance.ForeColor = Color.DarkBlue

        '	Set the ButtonAppearance of the relevant controls
        '	For the UltraComboEditor and UltraFontNameEditor, this appearance
        '	will be applied to their dropdown buttons. For the UltraNumericEditor
        '	and UltraCurrencyEditor, it will be applied to the spin buttons, and
        '	for the UltraDateTimeEditor, it will be applied to both.
        Me.ultraComboEditor1.ButtonAppearance = buttonAppearance
        Me.ultraFontNameEditor1.ButtonAppearance = buttonAppearance
        Me.ultraDateTimeEditor1.ButtonAppearance = buttonAppearance
        Me.ultraNumericEditor1.ButtonAppearance = buttonAppearance
        Me.ultraCurrencyEditor1.ButtonAppearance = buttonAppearance

        '	If the UltraComboEditor control has no items, add some now
        If (Me.UltraComboEditor1.Items.Count = 0) Then
            Me.UltraComboEditor1.Items.Add(1, "One")
            Me.UltraComboEditor1.Items.Add(2, "Two")
            Me.UltraComboEditor1.Items.Add(3, "Three")
        End If

        '	Set the ItemAppearance of the relevant controls to use the
        '	ButtonAppearance
        Me.UltraComboEditor1.ItemAppearance = Me.UltraComboEditor1.ButtonAppearance
        Me.UltraFontNameEditor1.ItemAppearance = Me.UltraFontNameEditor1.ButtonAppearance

        '	Set their ButtonStyle properties as well
        Me.UltraComboEditor1.ButtonStyle = UIElementButtonStyle.ButtonSoft
        Me.UltraFontNameEditor1.ButtonStyle = UIElementButtonStyle.ButtonSoft
        Me.UltraDateTimeEditor1.ButtonStyle = UIElementButtonStyle.ButtonSoft
        Me.UltraNumericEditor1.ButtonStyle = UIElementButtonStyle.ButtonSoft
        Me.UltraCurrencyEditor1.ButtonStyle = UIElementButtonStyle.ButtonSoft

        '	Make the spin buttons visible for the relevant controls
        Me.UltraDateTimeEditor1.SpinButtonDisplayStyle = ButtonDisplayStyle.Always
        Me.UltraNumericEditor1.SpinButtonDisplayStyle = ButtonDisplayStyle.Always
        Me.UltraCurrencyEditor1.SpinButtonDisplayStyle = ButtonDisplayStyle.Always
    End Sub
using System.Diagnostics;
using Infragistics.Win;
using Infragistics.Win.UltraWinEditors;

		private void SetupAppearance()
		{
			//	Create a new Appearance object
			Infragistics.Win.Appearance appearance = new Infragistics.Win.Appearance();
			
			//	Set some of the color properties of the Appearance object
			appearance.BackColor = Color.White;
			appearance.BackColor2 = Color.LightBlue;
			appearance.ForeColor = Color.DarkBlue;

			//	Set the background gradient style
			appearance.BackGradientStyle = GradientStyle.ForwardDiagonal;

			//	Set the AlwaysInEditMode property to false so gradient drawing
			//	will be enabled when the control does not have the input focus
			//
			//	Note that this only applies to the controls that use a TextBox for
			//	their edit portion (UltraTextEditor, UltraComboEditor, and UltraFontNameEditor)
			this.ultraTextEditor1.AlwaysInEditMode = false;
			this.ultraComboEditor1.AlwaysInEditMode = false;
			this.ultraFontNameEditor1.AlwaysInEditMode = false;

			//	Set each UltraWinEditor control's Appearance property to the
			//	Appearance object we just created, so they all have the same
			//	appearance
			this.ultraTextEditor1.Appearance = appearance;
			this.ultraComboEditor1.Appearance = appearance;
			this.ultraFontNameEditor1.Appearance = appearance;
			this.ultraDateTimeEditor1.Appearance = appearance;
			this.ultraNumericEditor1.Appearance = appearance;
			this.ultraCurrencyEditor1.Appearance = appearance;

			//	Create another Appearance object that we will assign to the
			//	ButtonAppearance property of the relevant controls
			Infragistics.Win.Appearance buttonAppearance = new Infragistics.Win.Appearance();
			buttonAppearance.BackColor = Color.AliceBlue;
			buttonAppearance.BackColorDisabled = Color.AliceBlue;
			buttonAppearance.ForeColor = Color.DarkBlue;

			//	Set the ButtonAppearance of the relevant controls
			//	For the UltraComboEditor and UltraFontNameEditor, this appearance
			//	will be applied to their dropdown buttons. For the UltraNumericEditor
			//	and UltraCurrencyEditor, it will be applied to the spin buttons, and
			//	for the UltraDateTimeEditor, it will be applied to both.
			this.ultraComboEditor1.ButtonAppearance = buttonAppearance;
			this.ultraFontNameEditor1.ButtonAppearance = buttonAppearance;
			this.ultraDateTimeEditor1.ButtonAppearance = buttonAppearance;
			this.ultraNumericEditor1.ButtonAppearance = buttonAppearance;
			this.ultraCurrencyEditor1.ButtonAppearance = buttonAppearance;

			//	If the UltraComboEditor control has no items, add some now
			if ( this.ultraComboEditor1.Items.Count == 0 )
			{
				this.ultraComboEditor1.Items.Add( 1, "One" );
				this.ultraComboEditor1.Items.Add( 2, "Two" );
				this.ultraComboEditor1.Items.Add( 3, "Three" );
			}

			//	Set the ItemAppearance of the relevant controls to use the
			//	ButtonAppearance
			this.ultraComboEditor1.ItemAppearance = this.ultraComboEditor1.ButtonAppearance;
			this.ultraFontNameEditor1.ItemAppearance = this.ultraFontNameEditor1.ButtonAppearance;

			//	Set their ButtonStyle properties as well
			this.ultraComboEditor1.ButtonStyle = UIElementButtonStyle.ButtonSoft;
			this.ultraFontNameEditor1.ButtonStyle = UIElementButtonStyle.ButtonSoft;
			this.ultraDateTimeEditor1.ButtonStyle = UIElementButtonStyle.ButtonSoft;
			this.ultraNumericEditor1.ButtonStyle = UIElementButtonStyle.ButtonSoft;
			this.ultraCurrencyEditor1.ButtonStyle = UIElementButtonStyle.ButtonSoft;

			//	Make the spin buttons visible for the relevant controls
			this.ultraDateTimeEditor1.SpinButtonDisplayStyle = ButtonDisplayStyle.Always;
			this.ultraNumericEditor1.SpinButtonDisplayStyle = ButtonDisplayStyle.Always;
			this.ultraCurrencyEditor1.SpinButtonDisplayStyle = ButtonDisplayStyle.Always;
		}
参照