Click here to Skip to main content
15,896,063 members
Articles / Programming Languages / C#

The Grid Processor: Word Processing Abilities for the .NET DataGridView Component

Rate me:
Please Sign up or sign in to vote.
4.87/5 (15 votes)
7 May 200711 min read 65.7K   1.6K   51  
A plugin which offers search and replace, casing and other capabilities for the Microsoft .NET DataGridView component
#region GNU notice
// GridProcessor - Search and replace abilities for the .NET DataGridView
// Copyright (C) 2007, by Evan Stein
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.

// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
#endregion GNU notice
using System;
using System.Collections.Generic;
using System.Text;

namespace GridProcessor
{
    /// <summary>
    /// An text-manipulation process, used to operate on a grid
    /// </summary>
    [Serializable]
    public class GridProcess
    {
        /// <summary>
        /// Database ID
        /// </summary>
        protected int mGridProcessID = -1;
        /// <summary>
        /// Type of process: replacement, casing, etc.
        /// </summary>
        protected int mGridProcessTypeID = -1;
        /// <summary>
        /// User-facing name of instruction
        /// </summary>
        protected string mName = string.Empty;
        /// <summary>
        /// User-facing description
        /// </summary>
        protected string mDescription = string.Empty;
        /// <summary>
        /// Expression used to identify items for operation
        /// </summary>
        protected string mSearchExpression = string.Empty;
        /// <summary>
        /// Replacement text or expression
        /// </summary>
        protected string mReplaceExpression = string.Empty;
        /// <summary>
        /// Use case-sensitivity in search (and?) replacement
        /// </summary>
        protected bool mCaseSensitive = false;
        /// <summary>
        /// Regard search/replacement text as Regex?
        /// </summary>
        protected bool mUseRegex = false;
        /// <summary>
        /// Make result uppercase?(?)
        /// </summary>
        protected bool mToUpper = true;
        /// <summary>
        /// Storage for column names used
        /// </summary>
        protected List<string> columnNames = new List<string>();
        /// <summary>
        /// Storage for search result
        /// </summary>
        protected FindResult mResult;

        /// <summary>
        /// Default constructor
        /// </summary>
        public GridProcess() 
        { 
        }

        /// <summary>
        /// Database ID
        /// </summary>
        public int ID
        {
            get { return mGridProcessID; }
            internal set { mGridProcessID = value; }
        }

        /// <summary>
        /// Is this a string replacement, case replacement, or other?
        /// </summary>
        public int GridProcessTypeID
        {
            get { return mGridProcessTypeID; }
            set { mGridProcessTypeID = value; }
        }

        /// <summary>
        /// Human-readable name for the set
        /// </summary>
        public string Name
        {
            get { return mName; }
            set { mName = value; }
        }

        /// <summary>
        /// Memory-jogging explanation
        /// </summary>
        public string Description
        {
            get { return mDescription; }
            set { mDescription = value; }
        }

        /// <summary>
        /// The expression identifying text to be replaced
        /// </summary>
        virtual public string SearchExpression
        {
            get { return mSearchExpression; }
            set { mSearchExpression = value; }
        }

        /// <summary>
        /// Should the search pay attention to upper- or lower-case?
        /// </summary>
        virtual public bool CaseSensitive
        {
            get { return mCaseSensitive; }
            set { mCaseSensitive = value; }
        }

        /// <summary>
        /// Are the search and replace expressions regular expressions?
        /// </summary>
        virtual public bool UseRegex
        {
            get { return mUseRegex; }
            set { mUseRegex = value; }
        }
    }
 
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United Kingdom United Kingdom
I'm a London-based software developer. Originally from New York, I came here in 1997 to run European application development for Standard & Poors. I now work independently ... and I'm still here!

Having seen how US software behaves outside the US, I'm keenly interested in problems of global and multilingual software design. I also used to write intelligence-gathering software, and still can't resist a well-turned algorithm! Before my IT career I was in music, and I'm now combining both interests in a highly-exciting 'Project-X'. I could tell you what it is, but ....

When not thinking about all of the above, I'm fascinated by all aspects of different cultures. (You can't take New York out of the New Yorker.) Interests include jazz, classical and world music, languages, history and ethnic food. I'm also an amateur travel writer and photographer, and run a site at www.travelogues.net, which you're welcome to stop by and visit!

Comments and Discussions