バージョン

xamDataGrid の Item クラスのサンプル コード

解説

このコードは、Item クラスを作成し、 INotifyPropertyChanged インターフェイスを継承します。

コード

Visual Basic の場合:

Namespace ExternalOperations
      Public Class Item
            Implements INotifyPropertyChanged
            Private m_a As String, m_b As String
            Private m_dateField As DateTime
            Private m_intField As Integer
            Private m_floatField As Single
            Private m_doubleField As Double
            Private m_decimalField As Decimal
            #Region "Properties"
            Public Property A() As String
                  Get
                        Return m_a
                  End Get
                  Set
                        If m_a <> value Then
                              m_a = value
                              OnPropertyChanged("A")
                        End If
                  End Set
            End Property
            Public Property B() As String
                  Get
                        Return m_b
                  End Get
                  Set
                        If m_b <> value Then
                              m_b = value
                              OnPropertyChanged("B")
                        End If
                  End Set
            End Property
            Public Property DateField() As DateTime
                  Get
                        Return m_dateField
                  End Get
                  Set
                        If m_dateField <> value Then
                              m_dateField = value
                              OnPropertyChanged("DateField")
                        End If
                  End Set
            End Property
            Public Property IntField() As Integer
                  Get
                        Return m_intField
                  End Get
                  Set
                        If m_intField <> value Then
                              m_intField = value
                              OnPropertyChanged("IntField")
                        End If
                  End Set
            End Property
            Public Property FloatField() As Single
                  Get
                        Return m_floatField
                  End Get
                  Set
                        If m_floatField <> value Then
                              m_floatField = value
                              OnPropertyChanged("FloatField")
                        End If
                  End Set
            End Property
            Public Property DoubleField() As Double
                  Get
                        Return m_doubleField
                  End Get
                  Set
                        If m_doubleField <> value Then
                              m_doubleField = value
                              OnPropertyChanged("DoubleField")
                        End If
                  End Set
            End Property
            Public Property DecimalField() As Decimal
                  Get
                        Return m_decimalField
                  End Get
                  Set
                        If m_decimalField <> value Then
                              m_decimalField = value
                              OnPropertyChanged("DecimalField")
                        End If
                  End Set
            End Property
            #End Region
            #Region "INotifyPropertyChanged"
            Public Event PropertyChanged As PropertyChangedEventHandler
            Private Sub OnPropertyChanged(propertyName As String)
                  RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
            End Sub
            #End Region
      End Class
End Namespace

C# の場合:

namespace ExternalOperations
{
    public class Item : INotifyPropertyChanged
    {
        private string a, b;
        private DateTime dateField;
        private int intField;
        private float floatField;
        private double doubleField;
        private decimal decimalField;
        #region Properties
        public string A
        {
            get { return a; }
            set
            {
                if (a != value)
                {
                    a = value;
                    OnPropertyChanged("A");
                }
            }
        }
        public string B
        {
            get { return b; }
            set
            {
                if (b != value)
                {
                    b = value;
                    OnPropertyChanged("B");
                }
            }
        }
        public DateTime DateField
        {
            get { return dateField; }
            set
            {
                if (dateField != value)
                {
                    dateField = value;
                    OnPropertyChanged("DateField");
                }
            }
        }
        public int IntField
        {
            get { return intField; }
            set
            {
                if (intField != value)
                {
                    intField = value;
                    OnPropertyChanged("IntField");
                }
            }
        }
        public float FloatField
        {
            get { return floatField; }
            set
            {
                if (floatField != value)
                {
                    floatField = value;
                    OnPropertyChanged("FloatField");
                }
            }
        }
        public double DoubleField
        {
            get { return doubleField; }
            set
            {
                if (doubleField != value)
                {
                    doubleField = value;
                    OnPropertyChanged("DoubleField");
                }
            }
        }
        public decimal DecimalField
        {
            get { return decimalField; }
            set
            {
                if (decimalField != value)
                {
                    decimalField = value;
                    OnPropertyChanged("DecimalField");
                }
            }
        }
        #endregion // Properties
        #region INotifyPropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;
        private void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion // INotifyPropertyChanged
    }
}

関連コンテンツ

トピック

このトピックについては、以下のトピックも参照してください。

トピック 目的

このトピックは、外部グルーピングを XamDataGrid で使用する方法について説明します。

このトピックは、 xamDataGrid の外部集計計算機能について説明します。