Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

ButtonBar Control using .NET

, 3 Dec 2009
Themed ButtonBar control supporting custom draw with full Designer support
using System.ComponentModel;

namespace ButtonBarsControl.Design.Generics
{
    /// <summary>
    /// Represents a method which can be used for Change events which will have <see cref="GenericChangeEventArgs{T}.OldValue"/>, <see cref="GenericChangeEventArgs{T}.NewValue"/> and <see cref="CancelEventArgs.Cancel"/>.
    /// </summary>
    /// <typeparam name="T">Type of object to be used for.</typeparam>
    /// <param name="sender">sender of Event.</param>
    /// <param name="e">Object containing event data</param>
    public delegate void GenericValueChangingHandler<T>(object sender, GenericChangeEventArgs<T> e);

    /// <summary>
    /// Place holder for change event containing Old and New Value.
    /// </summary>
    /// <typeparam name="T">Generic type</typeparam>
    public class GenericChangeEventArgs<T> : CancelEventArgs
    {
        private readonly T oldValue;

        /// <summary>
        /// Initializes new instance with specified parameter.
        /// </summary>/// 
        /// <param name="oldValue">Old Value.</param>
        /// <param name="newValue">New Value</param>
        public GenericChangeEventArgs(T oldValue, T newValue) : base(false)
        {
            this.oldValue = oldValue;
            NewValue = newValue;
        }

        /// <summary>
        /// Initializes new instance with specified parameter.
        /// </summary>/// 
        /// <param name="oldValue">Old Value.</param>
        /// <param name="newValue">New Value</param>
        /// <param name="cancel">Cancel flag which can be used to stop event execution.</param>
        public GenericChangeEventArgs(T oldValue, T newValue, bool cancel) : base(cancel)
        {
            this.oldValue = oldValue;
            NewValue = newValue;
        }

        /// <summary>
        /// Gets old value which is being modified.
        /// </summary>
        public T OldValue
        {
            get { return oldValue; }
        }

        /// <summary>
        /// Gets or Sets new Value which is being set for old value.
        /// </summary>
        public T NewValue { get; set; }
    }
}

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

Manish Ranjan Kumar
Software Developer (Senior)
India India
No Biography provided

| Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 3 Dec 2009
Article Copyright 2009 by Manish Ranjan Kumar
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid