Click here to Skip to main content
15,892,005 members
Articles / Programming Languages / C#

SourceGrid - Open Source C# Grid Control

Rate me:
Please Sign up or sign in to vote.
4.94/5 (429 votes)
4 Aug 2013MIT24 min read 4.9M   23.7K   1K  
SourceGrid is a free open source grid control. Supports virtual grid, custom cells and editors, advanced formatting options and many others features
using System;
using System.Drawing;
using System.Windows.Forms;

namespace SourceGrid2.Cells.Virtual
{
	/// <summary>
	/// A cell that contains a HTML style link. Use the click event to execute the link
	/// </summary>
	public abstract class Link : CellVirtual, ICellCursor
	{
		/// <summary>
		/// Constructor
		/// </summary>
		public Link()
		{
			VisualModel = VisualModels.Common.LinkStyle;
			Behaviors.Add(BehaviorModels.Cursor.Default);
		}

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="p_ExecuteLink">Event to execute when the user Click on this cell</param>
		public Link(PositionEventHandler p_ExecuteLink):this()
		{
			if (p_ExecuteLink!=null)
				Click+=p_ExecuteLink;
		}

		public event PositionEventHandler Click;

		public override void OnClick(PositionEventArgs e)
		{
			base.OnClick (e);

			if (Click!=null)
				Click(this, e);
		}

		/// <summary>
		/// Get the cursor of the specified cell
		/// </summary>
		/// <param name="p_Position"></param>
		public System.Windows.Forms.Cursor GetCursor(Position p_Position)
		{
			return System.Windows.Forms.Cursors.Hand;
		}
	}
}

namespace SourceGrid2.Cells.Real
{
	/// <summary>
	/// A cell that contains a HTML style link. Use the click event to execute the link
	/// </summary>
	public class Link : Cell
	{
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="p_Value"></param>
		public Link(object p_Value):base(p_Value)
		{
			VisualModel = VisualModels.Common.LinkStyle;
			Behaviors.Add(BehaviorModels.Cursor.Default);

			Cursor =  System.Windows.Forms.Cursors.Hand;
		}

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="p_Value"></param>
		/// <param name="p_ExecuteLink">Event to execute when the user Click on this cell</param>
		public Link(object p_Value, PositionEventHandler p_ExecuteLink):this(p_Value)
		{
			if (p_ExecuteLink!=null)
				Click+=p_ExecuteLink;
		}

		public event PositionEventHandler Click;

		public override void OnClick(PositionEventArgs e)
		{
			base.OnClick (e);

			if (Click!=null)
				Click(this, e);
		}
	}
}

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


Written By
Software Developer
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions