Click here to Skip to main content
15,875,656 members
Articles / Programming Languages / Visual Basic

Data Grid - Free Grid Control

Rate me:
Please Sign up or sign in to vote.
3.58/5 (6 votes)
20 Oct 2007CPOL2 min read 87.1K   25.1K   32   6
The best free grid control, you can choose any format (font name, bold, italic...) for each field and much more
Screenshot - vb_datagrid.jpg

Introduction

This is the best free grid control for VB 6. With this control, you can format each field (set font name, bold, italic, underline, align), it's very easy to use. Support AddRow and AddColumn. You can also auto add new row if you accessed to last row. Events (click, change...) give you indexes of last and new column/row. There are many properties, so you can easily create designs as per your wish (fore color, fore color selected, grid color, grid color fixed, back color, back color selected, back color fixed...).

There is also a property called RowFixedData where you can choose what will be printed in rowname field (its first column). You can choose between:

  • UserDefined – show text defined by programmer
  • RowNumber – auto generate row numbers and show them
  • SelectedPointer – Show * at selected row

Example Codes

VB.NET
' Setting row / column count:
Me.ucGrid1.Cols = 5
Me.ucGrid1.Rows = 1
' Set row / column names – if first index is 0 then you change column names, 
' if second index is 0 then you change row names:
Me.ucGrid1.Data(0, 1) = "ID"
Me.ucGrid1.Data(0, 2) = "Name"
Me.ucGrid1.Data(0, 3) = "Phone"

How to Use

This is a standard EXE project. If you want to add this to your project, you must copy all modules and user controls to your project directory. After that, you must add these files to your project.

If you want, you can create an ActiveX project and add this file to this project and create OCX.

Properties

  • AutoAddNextRow As Boolean – if True then control will automatically add new row when you access the last row
  • BackColor As OLE_COLOR – data back color
  • BackColorFixed As OLE_COLOR – row / column names back color
  • BackColorContainer As OLE_COLOR – user control back color
  • BackColorSelected As OLE_COLOR – selected field back color
  • Cols As Long – number of columns, when changed all data are deleted
  • Rows As Long – number of rows, when changed all data are deleted
  • Data(ByVal s_row As Long, ByVal s_col As Long) As String – data in selected field
  • Editable As Boolean – if True user can edit fields
  • FldAlign(ByVal mRow As Long, ByVal mCol As Long) As eAlign – (Left, Center or Right) field text (data) align
  • FldFontBold(ByVal mRow As Long, ByVal mCol As Long) As Boolean – field font bold
  • FldFontItalic(ByVal mRow As Long, ByVal mCol As Long) As Boolean – field font italic
  • FldFontName(ByVal mRow As Long, ByVal mCol As Long) As String – field font name
  • FldFontUnderline(ByVal mRow As Long, ByVal mCol As Long) As Boolean – field font underline
  • ForeColor As OLE_COLOR – data fore color
  • ForeColorFixed As OLE_COLOR – row / column name fore color
  • ForeColorSelected As OLE_COLOR – selected field fore color
  • GridColor As OLE_COLOR – grid color (where is data)
  • GridColorFixed As OLE_COLOR – grid color (where is row / col names)
  • SelectedCol As Long – return / set selected column
  • SelectedRow As Long – return / set selected row
  • Sizable As Boolean – if True, user can change field width / height

History

  • 20th October, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


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

Comments and Discussions

 
Questionvery nice grid Pin
abouldahab24-Jan-16 3:56
abouldahab24-Jan-16 3:56 
Questionmake this project Pin
reza nazari27-Jan-09 7:54
reza nazari27-Jan-09 7:54 
General[Message Removed] Pin
immetoz6-Oct-08 7:42
immetoz6-Oct-08 7:42 
QuestionHow to add "Merges cells" support to it? Pin
TommyChoi25-Dec-07 14:31
TommyChoi25-Dec-07 14:31 
GeneralVS6 :) Pin
ozkan.pakdil20-Oct-07 3:57
ozkan.pakdil20-Oct-07 3:57 
GeneralRe: VS6 :) Pin
Ivan000121-Oct-07 1:58
Ivan000121-Oct-07 1:58 

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

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