DataGridCell.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / WinForms / Managed / System / WinForms / DataGridCell.cs / 1 / DataGridCell.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Windows.Forms { 
 
    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis; 
    using System;
    using System.Globalization;

    ///  
    /// 
    ///    Identifies a cell in the grid. 
    ///  
    [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")]
    public struct DataGridCell { 
        private int rowNumber;
        private int columnNumber;

        ///  
        /// 
        /// Gets or sets the number of a column in the  control. 
        ///  
        public int ColumnNumber {
            get { 
                return columnNumber;
            }
            set {
                columnNumber = value; 
            }
        } 
 
        /// 
        ///  
        /// Gets or sets the number of a row in the  control.
        /// 
        public int RowNumber {
            get { 
                return rowNumber;
            } 
            set { 
                rowNumber = value;
            } 
        }

        /// 
        ///  
        ///    
        ///       Initializes a new instance of the  class. 
        ///     
        /// 
        public DataGridCell(int r, int c) { 
            this.rowNumber = r;
            this.columnNumber = c;
        }
 
        /// 
        ///  
        ///     
        ///       Gets a value indicating whether the  is identical to a second
        ///    . 
        ///    
        /// 
        [SuppressMessage("Microsoft.Usage", "CA2231:OverrideOperatorEqualsOnOverridingValueTypeEquals")]
        public override bool Equals(object o) { 
            if (o is DataGridCell) {
                DataGridCell rhs = (DataGridCell)o; 
                return (rhs.RowNumber == RowNumber && rhs.ColumnNumber == ColumnNumber); 
            }
            else 
                return false;
        }

        ///  
        /// 
        ///     
        ///       Gets 
        ///       a hash value that uniquely identifies the cell.
        ///     
        /// 
        public override int GetHashCode() {
            return ((~rowNumber * (columnNumber+1)) & 0x00ffff00) >> 8;
       } 

        ///  
        ///  
        ///    
        ///       Gets the row number and column number of the cell. 
        ///    
        /// 
        public override string ToString() {
            return "DataGridCell {RowNumber = " + RowNumber.ToString(CultureInfo.CurrentCulture) + 
                   ", ColumnNumber = " + ColumnNumber.ToString(CultureInfo.CurrentCulture) + "}";
        } 
 
    }
 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Windows.Forms { 
 
    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis; 
    using System;
    using System.Globalization;

    ///  
    /// 
    ///    Identifies a cell in the grid. 
    ///  
    [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")]
    public struct DataGridCell { 
        private int rowNumber;
        private int columnNumber;

        ///  
        /// 
        /// Gets or sets the number of a column in the  control. 
        ///  
        public int ColumnNumber {
            get { 
                return columnNumber;
            }
            set {
                columnNumber = value; 
            }
        } 
 
        /// 
        ///  
        /// Gets or sets the number of a row in the  control.
        /// 
        public int RowNumber {
            get { 
                return rowNumber;
            } 
            set { 
                rowNumber = value;
            } 
        }

        /// 
        ///  
        ///    
        ///       Initializes a new instance of the  class. 
        ///     
        /// 
        public DataGridCell(int r, int c) { 
            this.rowNumber = r;
            this.columnNumber = c;
        }
 
        /// 
        ///  
        ///     
        ///       Gets a value indicating whether the  is identical to a second
        ///    . 
        ///    
        /// 
        [SuppressMessage("Microsoft.Usage", "CA2231:OverrideOperatorEqualsOnOverridingValueTypeEquals")]
        public override bool Equals(object o) { 
            if (o is DataGridCell) {
                DataGridCell rhs = (DataGridCell)o; 
                return (rhs.RowNumber == RowNumber && rhs.ColumnNumber == ColumnNumber); 
            }
            else 
                return false;
        }

        ///  
        /// 
        ///     
        ///       Gets 
        ///       a hash value that uniquely identifies the cell.
        ///     
        /// 
        public override int GetHashCode() {
            return ((~rowNumber * (columnNumber+1)) & 0x00ffff00) >> 8;
       } 

        ///  
        ///  
        ///    
        ///       Gets the row number and column number of the cell. 
        ///    
        /// 
        public override string ToString() {
            return "DataGridCell {RowNumber = " + RowNumber.ToString(CultureInfo.CurrentCulture) + 
                   ", ColumnNumber = " + ColumnNumber.ToString(CultureInfo.CurrentCulture) + "}";
        } 
 
    }
 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK