Click here to Skip to main content
Click here to Skip to main content

Data Grid - Free Grid Control

, 20 Oct 2007
Rate this:
Please Sign up or sign in to vote.
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

' 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)

About the Author

Ivan0001

Croatia Croatia
No Biography provided

Comments and Discussions

 
Questionmake this project Pinmemberreza nazari27-Jan-09 7:54 
General[Message Removed] Pinmemberimmetoz6-Oct-08 7:42 
QuestionHow to add "Merges cells" support to it? PinmemberTommyChoi25-Dec-07 14:31 
GeneralVS6 :) Pinmembermascix20-Oct-07 3:57 
GeneralRe: VS6 :) PinmemberIvan000121-Oct-07 1:58 

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.

| Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 20 Oct 2007
Article Copyright 2007 by Ivan0001
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid