Click here to Skip to main content
12,359,102 members (68,692 online)
Click here to Skip to main content

Stats

339.6K views
6.1K downloads
480 bookmarked
Posted

User Settings Applied

, 5 Sep 2013 CPOL
Simplifying the .NET User Configuration for Windows Forms and WPF
Configuration
Properties
ConfigurationConsoleDemo
Properties
ConfigurationWindows
Properties
ConfigurationWindowsDemo
App.ico
Properties
ConfigurationWindowsForms
Properties
ConfigurationWindowsFormsDemo
App.ico
ConfigurationWindowsFormsDemo.csproj.user
Properties
Configuration2010.csproj.user
ConfigurationWindows2010.csproj.user
App.ico
ConfigurationWindowsDemo2010.csproj.user
App.ico
bin
Release
Itenso.Configuration.dll
Itenso.Configuration.Windows.dll
Itenso.Configuration.WindowsForms.dll
App.ico
App.ico
Itenso.Configuration.dll
Itenso.Configuration.Windows.dll
Itenso.Configuration.WindowsForms.dll
App.ico
App.ico
// -- FILE ------------------------------------------------------------------
// name       : DataGridViewColumnSetting.cs
// created    : Jani Giannoudis - 2008.05.09
// language   : c#
// environment: .NET 2.0
// --------------------------------------------------------------------------
using System;
using System.Windows.Forms;

namespace Itenso.Configuration
{

	// ------------------------------------------------------------------------
	[Serializable]
	internal class DataGridViewColumnSetting
	{

		// ----------------------------------------------------------------------
		public DataGridViewColumnSetting( DataGridViewColumn dataGridViewColumn )
		{
			if ( dataGridViewColumn == null )
			{
				throw new ArgumentNullException( "dataGridViewColumn" );
			}

			DisplayIndex = dataGridViewColumn.DisplayIndex;
			Width = dataGridViewColumn.Width;
			Name = dataGridViewColumn.Name;
			Visible = dataGridViewColumn.Visible;
		} // DataGridViewColumnSetting

		// ----------------------------------------------------------------------
		public int DisplayIndex { get; set; }

		// ----------------------------------------------------------------------
		public int Width { get; set; }

		// ----------------------------------------------------------------------
		public string Name { get; set; }

		// ----------------------------------------------------------------------
		public bool Visible { get; set; }

		// ----------------------------------------------------------------------
		public override bool Equals( object obj )
		{
			if ( obj == this )
			{
				return true;
			}

			DataGridViewColumnSetting compare = obj as DataGridViewColumnSetting;
			if ( compare == null )
			{
				return false;
			}

			return
				string.Equals( Name, compare.Name ) &&
				int.Equals( DisplayIndex, compare.DisplayIndex ) &&
				int.Equals( Width, compare.Width ) &&
				bool.Equals( Visible, compare.Visible );
		} // Equals

		// ----------------------------------------------------------------------
		public override int GetHashCode()
		{
			int hash = GetType().GetHashCode();
			hash = AddHashCode( hash, Name );
			hash = AddHashCode( hash, DisplayIndex );
			hash = AddHashCode( hash, Width );
			hash = AddHashCode( hash, Visible );
			return hash;
		} // GetHashCode

		// ----------------------------------------------------------------------
		private static int AddHashCode( int hash, object obj )
		{
			int combinedHash = obj != null ? obj.GetHashCode() : 0;
			if ( hash != 0 )
			{
				combinedHash += hash * 31;
			}
			return combinedHash;
		} // AddHashCode

	} // class DataGridViewColumnSetting

} // namespace Itenso.Configuration
// -- EOF -------------------------------------------------------------------

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Jani Giannoudis
Software Developer (Senior)
Switzerland Switzerland
Jani is Co-founder of Meerazo.com, a free service which allows to share resources like locations, things, persons and their services in a cooperating group of people.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160621.1 | Last Updated 5 Sep 2013
Article Copyright 2008 by Jani Giannoudis
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid