すらすらプログラマーへのお問い合わせ
すらすらのブログ
アクセス数  累計:000,102,775  昨日:000,000,133  本日:000,000,024
Loading
プロパティグリッド
.NET プログラミング
プロパティグリッド
印刷
リストボックス
スレッド
リストビュー
インストーラー
やってみよう!

できるVisual Studio 2015 Windows /Android/iOS アプリ対応

独習C# 第3版

VisualBasic2013パーフェクトマスター (Perfect Master SERIES)

プログラミング.NET Framework 第4版 (Microsoft Press)

VisualBasic2013逆引き大全555の極意

猫でもわかるWindowsプログラミング 第4版 (猫でもわかるプログラミング)

VisualC#2013逆引き大全555の極意

説明文の表示 最終更新:2010/07/15
【Amazon ランキング:DVD - 海外映画】

プロパティグリッドの下に表示される説明文ですが、プロパティ名だけでは機能がわかりにくい時のとても役に立ちます。
自分が作ったクラスやコントロールをほかの人に渡すときに説明を書いておくと手間が省けて便利です。
プロパティに属性をつける
説明文は公開プロパティに次の属性を付加することで表示できます。
[VB]
<System.ComponentModel.Category("すらすら")>
<System.ComponentModel.Description("bool 値のプロパティ")>

[C#]
[System.ComponentModel.Category("すらすら")]
[System.ComponentModel.
Description("bool 値プロパティ")]
Category 属性でプロパティをグループ化して、それぞれのプロパティの説明文は Description で定義します。プロパティの機能ごとに Category で分類して使いやすくしましょう。

VB[Class1.vb]
Public Class Class1

    
' クラスメンバ変数
    Private _boolValue As Boolean = False
    Private _intValue As Integer = 0
    
Private _stringValue As String = "SuraSura"
    Private _colorValue As Color = Color.White

    
' bool値プロパティ
    <System.ComponentModel.Category("すらすら")> _
    
<System.ComponentModel.Description("bool 値のプロパティ")> _
    
Public Property BoolValue() As Boolean
        Get
            Return _boolValue
        
End Get
        Set(ByVal value As Boolean)
            _boolValue = value
        
End Set
    End Property

    ' int値プロパティ
    <System.ComponentModel.Category("すらすら")> _
    
<System.ComponentModel.Description("int 値のプロパティ")> _
    
Public Property IntValue() As Integer
        Get
            Return _intValue
        
End Get
        Set(ByVal value As Integer)
            _intValue = value
        
End Set
    End Property

    ' String値プロパティ
    <System.ComponentModel.Category("すらすら")> _
    
<System.ComponentModel.Description("String 値のプロパティ")> _
    
Public Property StringValue() As String
        Get
            Return _stringValue
        
End Get
        Set(ByVal value As String)
            _stringValue = value
        
End Set
    End Property

    ' Color値プロパティ
    <System.ComponentModel.Category("すらすら")> _
    
<System.ComponentModel.Description("Color 値のプロパティ")> _
    
Public Property ColorValue() As Color
        
Get
            Return _colorValue
        
End Get
        Set(ByVal value As Color)
            _colorValue = value
        
End Set
    End Property

End
 Class
C#[Class1.cs]
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace PropatyGrid_CS
{
    
public class Class1
    {
        
// クラスメンバ変数
        bool _boolValue = false;
        
int _intValue = 0;
        
string _stringValue = "SuraSura";
        
Color _colorValue = Color.White;

        
// bool値プロパティ
        [System.ComponentModel.Category("すらすら")]
        
[System.ComponentModel.Description("bool 値プロパティ")]
        
public bool BoolValue
        {
            
get { return _boolValue; }
            
set { _boolValue = value; }
        }

        
// int値プロパティ
        [System.ComponentModel.Category("すらすら")]
        
[System.ComponentModel.Description("int 値プロパティ")]
        
public int IntValue
        {
            
get { return _intValue; }
            
set { _intValue = value; }
        }

        
// String値プロパティ
        [System.ComponentModel.Category("すらすら")]
        
[System.ComponentModel.Description("String 値プロパティ")]
        
public string StringValue
        {
            
get { return _stringValue; }
            
set { _stringValue = value; }
        }

        
// Color値プロパティ
        [System.ComponentModel.Category("すらすら")]
        
[System.ComponentModel.Description("Color 値プロパティ")]
        
public Color ColorValue
        {
            
get { return _colorValue; }
            
set { _colorValue = value; }
        }
    }
}
※このページで紹介しているサンプルコードについて管理者は動作保障をいたしません※
※サンプルコードを使用する場合は、自己責任でお願いします※

【楽天 ランキング:パソコン・周辺機器 - パソコンパーツ】




このサイトはフリーソフトのMerge HTMLで作成されています。
このサイトはリンクフリーです。

ページの先頭に戻る Copyright© 2010-2015 Jun.Shiozaki All rights reserved.