Click here to Skip to main content
Licence 
First Posted 17 Nov 2003
Views 98,239
Bookmarked 51 times

C# grid control

By | 17 Nov 2003 | Article
A C# grid control.

Sample Image - grid_control.jpg

Introduction

This is a simple C# grid control. The control provides a way to display and edit string’s collection. When your program wants to get input from user, generally, you can put EditBox control on your form. But when you need to get a set of dates, the EditBox control is not the best choice. Do we have another choice? Try this, maybe it is appropriate for you.

The control features

  • In-place edit
  • Insert rows and columns
  • Cell copy and paste
  • Line copy and paste
  • Multi-line copy and paste
  • Mark a line
  • Display multi-line in a cell
  • Changing column width with mouse at runtime
  • VS.NET IDE integration

How to use?

Simply add the control to you VS.NET Toolbox, then you can drop it to your form. That’s all, no other. Once you create an instance of this control in your form, you can add columns in IDE environment or dynamically add columns at run-time.

Properties

Type Name Description
Cell ActivateCell Return or specify current active cell
ColumnCollection Columns Columns collection
Font Font  
Font HeaderFont The header font
RowCollection Rows Rows collection
Bool HasGridLine Whether display table lines
Bool ReadOnly  

Methods

Return Type Name Parameter Description
Void AppendRow   Append a black row
Void AppendRow String[] val Append a row with specified value
Void InsertRow Int index Insert a row at the position that is specified by index parameter
Void InsertRow

Int index

String[] val

Insert a row at the position that is specified by index parameter and fill the cell value with val parameter
Void ClearAll   Empty all cell content
Void Refresh   Force grid control repaint
Void RemoveRow Int index Remove the row that is specified by index parameter
Void SetCell

Int row

Int col

String val

Set the value of the cell which is specified by row and col parameter to val
Void SetCell

Int row

Int col

String[] val

Set the value of the cell which is specified by row and col parameter to val
String GetCell

Int row

Int col

Get the value of the cell which is specified by row and col parameters
Void MarkRow Int index Draw an arrow at the left of the row specified by index

Events

Name Description
RowSelected When a row is selected it throws this event
ActiveCellChanged When the ActiveCell changes, it throws this event

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

About the Author

linjie

Web Developer

China China

Member

He's in the dust

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMouseWheel event Pinmemberkostickaa14:45 1 Apr '08  
GeneralRe: MouseWheel event Pinmemberlinjie17:03 1 Apr '08  
QuestionInsert row into database Pinmemberpeperoneca3:03 15 Aug '06  
General你的个人网站怎么上不去啊?? PinmemberJack.Yao23:04 19 Apr '04  
GeneralRe: 你的个人网站怎么上不去啊?? Pinmemberlinjie16:35 26 Jun '04  
Generalnot fully tested... PinmemberAlex Kucherenko4:21 25 Nov '03  
GeneralRe: not fully tested... Pinmemberlinjie15:14 25 Nov '03  
GeneralRe: not fully tested... Pinmemberelitecommerceserver5:06 26 Nov '03  
GeneralRe: not fully tested... Pinmemberlinjie21:49 26 Nov '03  
Generalamazing work ! PinmemberRetish P12:19 19 Nov '03  
Generallink is ok now. Pinmemberlinjie4:37 19 Nov '03  
Generalcodejock PinsussGnupe1:39 19 Nov '03  
GeneralRe: codejock Pinmemberlinjie4:21 19 Nov '03  
General*tut* + *sigh* Pinmemberdog_spawn12:02 19 Nov '03  
GeneralRe: codejock PinmemberRabidKangaroo11:41 19 Nov '03  
GeneralUnworked Link to SouceCode Pinmembertim_mcgwyn0:58 19 Nov '03  
GeneralLink to the Source PinmemberSanjay Rastogi0:43 19 Nov '03  
GeneralLink to the source PinmemberJuergen Posny0:20 19 Nov '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 18 Nov 2003
Article Copyright 2003 by linjie
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid