Click here to Skip to main content
13,704,402 members
Click here to Skip to main content

Stats

3M views
19.8K downloads
994 bookmarked
Posted 19 Jan 2003
Licenced MIT

SourceGrid - Open Source C# Grid Control

, 4 Aug 2013
SourceGrid is a free open source grid control. Supports virtual grid, custom cells and editors, advanced formatting options and many others features
SourceGrid2
References
SourceLibrary.dll
vssver.scc
SampleProject
App.ico
bin
Release
SampleProject.exe
SourceGrid2.dll
SourceLibrary.dll
Extensions
Add.ico
ArrowDown.ICO
ArrowUp.ICO
Delete.ICO
Refresh.ico
vssver.scc
Samples
CalcioSmall.bmp
FACE00.ICO
FACE01.ICO
FACE02.ICO
FACE04.ICO
new.bmp
vssver.scc
SourceGrid
BehaviorModels
vssver.scc
bin
Release
SourceGrid2.dll
SourceLibrary.dll
vssver.scc
Cells
vssver.scc
Common
Icons
CheckBoxChecked.ico
CheckBoxCheckedDisable.ico
CheckBoxCheckedSel.ico
CheckBoxUnChecked.ico
CheckBoxUnCheckedDisable.ico
CheckBoxUnCheckedSel.ico
clear.ico
copy.ico
cut.ico
DeleteCol.ico
DeleteRow.ico
InsertCol.ico
InsertRow.ico
paste.ico
properties.ico
SortDown.ico
SortUp.ico
Thumbs.db
vssver.scc
vssver.scc
DataModels
vssver.scc
Grid.bmp
Grids
vssver.scc
GridVirtual.bmp
SourceGrid2.snk
VisualModels
vssver.scc
SourceGrid
DemoProject
App.ico
bin
Release
DemoProject.exe
SourceGrid.dll
SourceLibrary.dll
FACE00.ICO
FACE01.ICO
FACE02.ICO
FACE04.ICO
new.bmp
PropertyStyleGrid
WorksheetStyleGrid
References
SourceLibrary.dll
SourceGrid
bin
Release
SourceGrid.dll
Cells
Models
PropertyStyleGrid
SourceGrid.snk
TypeCreator
Utility
Chris.Beckett.MenuImageLib
SubItem16.ico
Control
Controls
Icons
CheckBoxChecked.ico
CheckBoxCheckedDisable.ico
CheckBoxCheckedSel.ico
CheckBoxUnChecked.ico
CheckBoxUnCheckedDisable.ico
CheckBoxUnCheckedSel.ico
clear.ico
copy.ico
cut.ico
DeleteCol.ico
DeleteRow.ico
InsertCol.ico
InsertRow.ico
paste.ico
properties.ico
SortDown.ico
SortUp.ico
WorksheetStyleGrid
using System;
using System.Windows.Forms;

namespace SourceGrid
{
	/// <summary>
	/// Rappresents a model of a cell, used for editing operation, string conversion and cell value formatting
	/// </summary>
	public interface ICellModel
	{
		#region Editing
		/// <summary>
		/// Cell in editing, if null no cell is in editing state
		/// </summary>
		Cell EditCell
		{
			get;
		}
		/// <summary>
		/// Start editing the cell passed
		/// </summary>
		/// <param name="p_Cell">Cell to start edit</param>
		/// <param name="p_StartEditValue">Can be null(in this case use the p_cell.Value</param>
		void StartEdit(Cell p_Cell, object p_StartEditValue);
		/// <summary>
		/// Apply the edit action to the cell, this method doesn't finish the edit action
		/// </summary>
		/// <returns>True if the new value is inserted in the cell</returns>
		bool ApplyEdit();
		/// <summary>
		/// Terminate the edit action
		/// </summary>
		/// <param name="p_Cancel">True to cancel the editing and return to normal mode, false to call automatically ApplyEdit and terminate editing</param>
		/// <returns>Returns true if the cell terminate the editing mode</returns>
		bool EndEdit(bool p_Cancel);


		/// <summary>
		/// Returns true if the cell is in editing state
		/// </summary>
		bool IsEditing
		{
			get;
		}

		/// <summary>
		/// Enable or disable the cell editor (if disable no edit is allowed)
		/// </summary>
		bool EnableEdit
		{
			get;
			set;
		}
		#endregion

		#region Modify Functions
		/// <summary>
		/// Clear the cell applying the rule of the current editor
		/// </summary>
		/// <param name="p_Cell">Cell to be cleared</param>
		void ClearCell(Cell p_Cell);

		/// <summary>
		/// Change the value of the cell applying the rule of the current editor
		/// </summary>
		/// <param name="p_Cell">Cell to change value</param>
		/// <param name="p_NewValue">Value to set</param>
		/// <returns>returns true if the value passed is valid and has been applied to the cell</returns>
		bool SetCellValue(Cell p_Cell, object p_NewValue);
		#endregion

		#region Validating
		/// <summary>
		/// check if the value passed is valid for the current CellEditor
		/// </summary>
		/// <param name="p_Value"></param>
		/// <returns></returns>
		bool IsValidValue(object p_Value);
		/// <summary>
		/// Fired when we must check if a value is valid for the current ICellModel
		/// for example by the IsValidValue method and the 
		/// Validating event internally call this method to check if the value specified by the user is allowed)
		/// </summary>
		event ValidatingEventHandler ValidatingValue;
		/// <summary>
		/// Fired to check if the value specified by the user is allowed
		/// this event is fired after the ValidatingValue (use ValidatingValue to check if the value is compatible with the cell)
		/// </summary>
		event ValidatingCellEventHandler Validating;
		/// <summary>
		/// Fired after the value specified by the user inserited in the cell
		/// </summary>
		event CellEventHandler Validated;
		/// <summary>
		/// Check if a string is valid 
		/// </summary>
		/// <param name="p_strValue"></param>
		/// <returns></returns>
		bool IsValidString(string p_strValue);

		#endregion


		#region Conversion
		/// <summary>
		/// Convert the p_strValue to a object according to the current Editor
		/// If the string is not valid for the current Editor an exception will be throw
		/// </summary>
		/// <param name="p_strValue"></param>
		/// <returns></returns>
		object StringToObject(string p_strValue);

		/// <summary>
		/// Convert p_ObjValue to a string according to the current Editor
		/// If the object is not valid for the current Editor an exception will be throw
		/// </summary>
		/// <param name="p_ObjValue"></param>
		/// <returns></returns>
		string ObjectToString(object p_ObjValue);

		/// <summary>
		/// Indicates if the current Editor support string conversion 
		/// </summary>
		bool SupportStringConversion
		{get;}

		/// <summary>
		/// If the formatter doesn't support string conversion use this method to retrive a string rappresentation of the object
		/// this string cannot be used to conversion
		/// </summary>
		/// <param name="p_Value"></param>
		/// <returns></returns>
		string GetStringRappresentation(object p_Value);

		/// <summary>
		/// String used when the real Value is null
		/// </summary>
		string NullString
		{
			get;
		}

		/// <summary>
		/// String used when error occurred
		/// </summary>
		string ErrorString
		{
			get;
		}

		/// <summary>
		/// Check if the given string is null
		/// </summary>
		/// <param name="p_str"></param>
		/// <returns></returns>
		bool IsNullString(string p_str);

		/// <summary>
		/// Check if the given string is error
		/// </summary>
		/// <param name="p_str"></param>
		/// <returns></returns>
		bool IsErrorString(string p_str);

		/// <summary>
		/// Get a list of possible value for this Formatter
		/// or null if no value is suggested
		/// </summary>
		System.Collections.ICollection StandardValues
		{
			get;
		}
		#endregion


		#region Export Import
		/// <summary>
		/// Export the value to a string (used for example in the copy and paste operation)
		/// </summary>
		/// <param name="p_ObjValue"></param>
		/// <returns></returns>
		string ExportValue(object p_ObjValue);

		/// <summary>
		/// Import the value from a string (used for example in the copy and paste operation)
		/// </summary>
		/// <param name="p_strImport"></param>
		/// <returns></returns>
		object ImportValue(string p_strImport);
		#endregion
	}
}

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 MIT License

Share

About the Author

Davide Icardi
Software Developer
Italy Italy
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180920.1 | Last Updated 4 Aug 2013
Article Copyright 2003 by Davide Icardi
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid