Click here to Skip to main content
Licence CPOL
First Posted 26 Feb 2007
Views 17,329
Downloads 318
Bookmarked 17 times

DataGrid Control, EditText Control

By | 26 Feb 2007 | Article
An article on yet another DataGrid Control

Screenshot - DataGridDemo.jpg

Introduction

This article presents a DataGrid control which is built with no MFC, no C++. It can be used in SDK or MFC Win32 applications.

Background

You can find various grid controls all over the Internet, some free and some not. The DataGrid control is attempt of realization of datagrid like msdatgrd.ocx from VB 6.0 with no ActiveX interface.

Using the code

To use this code you must define your datasource and register the following function:

1. int GetRecordCount( void )
2. int GetCountColumns( void )
3. char* GetColumnName( iIndexColumn )
4. char* GetValue( int iNumRow, int iNumField )
5. void SetValue( int iNumRow, int iNumField, char *szValue )

FARPROC fn;

fn=GetProcAddress( (HMODULE)hInstDLL, "DataGridFrameRegisterDataFunction" );
DataGridFrameRegisterDataFunction=(TDataGridFrameRegisterDataFunction)fn;
iRes=(*DataGridFrameRegisterDataFunction)(&ODBCGetRecordCount, 
&ODBCGetCountColumns,&ODBCGetColumnName,&ODBCGetValue, &ODBCSetValue);
if( iRes==0 )
{
...
}

If your datasource is insertable set bInsert=TRUE, if deletable set bDelete=TRUE, if updatable set bUpdate=TRUE. Then

fn=GetProcAddress( (HMODULE)hInstDLL, "DataGridSetDataAttribs" );
DataGridSetDataAttribs=(TDataGridSetDataAttribs)fn;
iRes=(*DataGridSetDataAttribs)( bInsert, bDelete, bUpdate );
if( iRes==0 )
{
...
}

If you want to catch events, you should define and register handlers.

fn=GetProcAddress( (HMODULE)hInstDLL, "DataGridSetEvents" );
DataGridSetEvents=(TDataGridSetEvents)fn;
iRes=(*DataGridSetEvents)( &OnHeadClick, &OnRowColChange, &OnAfterDelete, 
&OnBeforeColEdit );

See source code for details.

License

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

About the Author

IlyasovAM



Russian Federation Russian Federation

Member



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
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 26 Feb 2007
Article Copyright 2007 by IlyasovAM
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid