您的位置:首页 > 其它

DataGrid Control, EditText Control

2012-11-28 13:09 218 查看

DataGrid Control, EditText Control

By IlyasovAM,
26 Feb 2007




1.64 (6 votes)


1


2


3


4


5
1.64/5 - 6 votes
μ 1.64, σa 2.80 [?]


Is your email address OK? You are signed up for our newsletters but your
email address is either unconfirmed, or has not been reconfirmed in a long time. Please click

here to have a confirmation email sent so we can confirm your email address and start sending you newsletters again. Alternatively, you can

update your subscriptions.

Download DataGridDemo.zip - 122.9 KB



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:


Collapse |
Copy Code
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


Collapse |
Copy Code
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.


Collapse |
Copy Code
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



Member

No Biography provided
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: