Copyright: Copyright 1996 ProtoView Development Corp


Contents

 Getting Started with the DataTable
Provides an introduction and essential information you need to know before programming the DataTable.

 Tutorials
Use the tutorials to gain an understanding of the DataTable.

 Programming the DataTable
Provides help on programming the DataTable.

 The DataTable Reference Guide
Provides a refrence to DataTable messages, notiications, functions and structures.


 Programming the DataTable

This section covers the DataTable objects.

The DataTable Object

Column Objects

Row Object

Cell Object

The Current Cell Object


 Introduction

What is the DataTable Control?

Installing DataTable 3.1

Product Support

Document Conventions


 Getting Started with the DataTable

Introduction

The DataTable Object Hierarchy

Building a Visual Basic DataTable Application

Building a Visual C++ DataTable Application

Building a Delphi DataTable Application

The ProtoView DataTable Control Properties Dialog

The DataTable User Interface


 Tutorials

Visual Basic Example

Visual Basic Bound Example

Visual C++ Example

Delphi Example


 The DataTable Object

DataTable Object Overview

The DataTable Appearance

Reset All DataTable Information

Window Splitting

Owner Drawn Cells

Virtual Memory


 Column Objects

Column Objects Overview

Manipulating DataTable Columns

Column Appearance

Column Data

Column Searching

Column Sorting

Column Symbolic Names

Selecting Columns

The Row Label Column


 Row Objects

Row Objects Overview

Manipulating DataTable Rows

Row Appearance

Row Data

Selecting Rows

The Column Headings Row


 Cell Objects

Cell Objects Overview

Cell Appearance

The Cell Data

Null Cell Flagging

Selecting Blocks


 The Current Cell Object

The Current Cell Object Overview

The Current Cell Appearance

Editing the Current cell

The Current Cell Data

Moving the Current Cell


 The DataTable Reference Guide

The DataTable Object Reference

The DTCurCell Object Reference

The DTColumnSet Object Reference

The DTColumn Object Reference

The DTRowSet Object Reference

The DTRow Object Reference

The DTCellSet Object Reference

The DTCell Object Reference

The Event Reference

The Constants Reference


 The DataTable Object Reference

The DataTable Object Properties

The DataTable Object Methods


The Current Cell Object Reference
 The DTCurCell Object Reference

The DTCurCell Object Properties

The DTCurCell Object Methods


The Column Set Object Reference
 The DTColumnSet Object Reference

The DTColumnSet Object Properties

The DTColumnSet Object Methods


The Column Object Reference
 The DTColumn Object Reference

The DTColumn Object Properties

The DTColumn Object Methods


The Row Set Object Reference
 The DTRowSet Object Reference

The DTRowSet Object Properties

The DTRowSet Object Methods


The Row Object Reference
 The DTRow Object Reference

The DTRow Object Properties

The DTRow Object Methods


The Cell Set Object Reference
 The DTCellSet Object Reference

The DTCellSet Object Properties

The DTCellSet Object Methods


The DataTable Cell Object Reference
 The DTCell Object Reference

The DTCell Object Properties

The DTCell Object Methods


 The Event Reference

Event Category Reference

Event Alphabetical Reference


 Event Alphabetical Reference

AbortEdit Event

BeforeAbortEdit Event

BeforeBeginEdit Event

BeforeBlockSel Event

BeforeColSel Event

BeforeCopy Event

BeforeCut Event

BeforeDeleteRow Event

BeforeEndEdit Event

BeforeInsertRow Event

BeforePaste Event

BeforeRowSel Event

BeginEdit Event

BlockSel Event

BlockUnSel Event

CellFull Event

Change Event

ColAdded Event

ColChange Event

ColDeleted Event

ColMoved Event

ColNameChanged Event

ColSel Event

ColSize Event

ColUnSel Event

ComboCloseUp Event

ComboDropDn Event

Create Event

DeletedRow Event

Destroy Event

DropDn Event

EditKeyDown  Event

EditKeyPress Event

EditKeyUp Event

Error Event

HScroll Event

InsertedRow Event

KeyDown Event

KeyPress Event

KeyUp Event

LfClick Event

LfDblClick Event

MouseDown Event

MouseMove Event

MouseUp Event

PaintCell Event

PosChange Event

RowChange Event

RowSel Event

RowSize Event

RowUnSel Event

RtClick Event

RtDblClick Event

UpdateCell Event

VMGetFirst Event

VMGetLast Event

VMGetNext Event

VMGetPercent Event

VMGetPrev Event

VMGetRowData Event

VScroll Event


 Constants

 	Appearance Constants

Color Constants

Data Edit Constants

Data Type Constants

Drop Down Constants

Focus Pen Style Constants

Heading Type Constants

Horizontal Alignment Constants

Label Type Constants

Pane Constants

Pane Size Constants

Position Constants

Resize Constants

Row and Column Index Constants

Scroll Bar Constants

Select Constants

Sort Key Constants

Vertical Alignment Constants

Virtual Memory Type Constants


Introduction


What is the DataTable Control?

The DataTable control is an OLE control capable of managing, displaying, and editing rows, columns and cells of data in a spreadsheet like manner.  The DataTable is useful in displaying the values of two dimensional arrays or for presenting the results of SQL queries.  The DataTable can also be used as a data entry tool.  A wide variety of properties and methods are available for customizing the DataTable look and behavior including window splitting, colors, fonts, sorting, grid lines, column headings, row labels and the ability for users to select either single or multiple rows, columns and blocks.

A DataTable

The DataTable is able to manage over 2 billion rows of data, given the availability of sufficient memory.

Each column in a DataTable can be defined to be one of a number of data types: 2 and 4 byte integers, 4 and 8 byte floating point numbers, strings, check boxes, currency, date, time, and bitmaps.

Each column has its own customizable styles, including justification of both the column heading and the column data, whether to show or hide the column, whether or not to scroll the column horizontally, and whether to enable or disable its ability to be edited and resized by the user.  Columns also have their own customizable properties, including the width of their display, their column heading label, the display format of their data, and their name.

A cell (the data for a column in a row) may contain up to 1000 bytes depending on its column's data type.

A DataTable can employ a Virtual Memory Managed scheme.  In a Virtual Memory Managed  DataTable, the DataTable stores only the visible page of data, requesting additional information from the owner when the table is scrolled.  There is no limit to the number of rows in a Virtual Memory Managed table.

Like all controls, a DataTable notifies its parent of significant events, making it possible to program a very sophisticated user/computer interaction.


Installing DataTable 3.1

Before installing the DataTable, read the licensing agreement included in the product package and make a backup copy of the installation disk.

Perform the following steps to install the DataTable.

1.   Insert the disk labeled "Setup" into drive A or B.

2.   Start Microsoft Windows.

3.   If you are using Windows 95, press the Start button and then select the menu item Run.  If you are using Windows 3.1 or Windows NT, select File and then Run from the Program Managers menu.

4.   In the Command Line edit box of the Run dialog, enter "A:\SETUP" or "B:\SETUP" depending on the drive where you inserted the setup disk.

5.   Click OK.

6.   Follow the instructions given by the installation program.

7.   After the installation is complete, the install program will ask if you want to read the README. DOC file.  Select "Yes".


Product Support

If you have questions about the DataTable, you may contact our Technical Support staff.  ProtoView now offers different types of  technical support services for you to choose from including 30 days of complimentary telephone support, standard support, and available extended support packages.

When contacting our Technical Support staff, please provide the following information:

•	Your Customer ID.

•	The version of DataTable you are using and the file dates of any updates you have installed.

•	The exact wording of any messages that appeared on your screen.

•	The error code returned from the message you are having a problem with.

•	A brief and concise explanation of the question or problem that you are experiencing.

•	How you tried to solve the problem.

Complimentary Technical Support

If you are a registered user, free technical support is available by telephone for 30 days from the date of your first telephone call.  (Standard Technical Support is always available at no charge.)

To obtain technical support by telephone, call (609) 655-5000.  Technical Support hours are Monday through Friday, 9:00 A.M. to 5:00 P.M. Eastern Standard Time (excluding holidays).

Standard Technical Support

Available at no charge,  Standard Technical Support provides all registered users with technical support through the following services:

Bulletin Board Services(BBS)

ProtoView Development maintains a 24 hour Bulletin Board Service.  This bulletin board is available for technical questions and problem reports.  It also contains updated information about DataTable along with a library of examples and source code that can be downloaded for your own use.

This service is free of charge to all DataTable users and can be reached at (609) 655-4411.  The communication parameters are 14.4/9600/2400/1200/300,8,N,1.

CompuServe Forum

You can join ProtoView on CompuServe where you can ask questions, download files and communicate with other ProtoView and DataTable users.  To access the ProtoView forum on CompuServe, type GO PROTOVIEW at the CompuServe command prompt.

Internet Support

You can join ProtoView on the Internet by pointing your browser to http:\\www.protoview.com.  Please address technical support to tech@protoview.com.

ProtoView Technical Fax

You may also ask about a problem or question by sending a facsimile message.  The number for faxing is (609) 655-5353.  Be sure to include your name, fax number, telephone number and as much information about the problem as possible.  Our technical support personnel will review your questions and fax back a reply.

Extended Support Packages

Several support packages are available at an additional charge.  ProtoView offers priority, premier, and pay-as-you-go support options.  Call ProtoView sales department at 1-800-231-8588 for additional information  about the different support packages available.

Product Training and Consultation Services

Within the United States, ProtoView Development offers the following services for training and consultation.

ProtoView Professional Services

ProtoView Professional Services offers education and training in many areas of Windows programming with and without the DataTable.  Both beginning and advanced courses are available in 3 or 5 day units

ProtoView Professional Services has highly skilled and experienced personnel available for the development of Windows applications and systems.  These services can be provided on-site, off-site, full or part time.  For more information, PPS can be reached at 1-800-231-8588 or 770-390-6226.


Document Conventions

The DataTable OCX manual uses the following typographic conventions.

Example	Description
HorzGridLines	Properties are displayed in Bold
dtAfterLast	Constants are displayed in Courier New font.
Status	Parameters are italics
OK	Control and dialog names are in quotes


The DataTable Object Hierarchy

The DataTable is composed of objects which group related methods and properties together.  Just like a file cabinet contains drawers and each drawer contains files, the DataTable contains objects and these objects contain other objects.

The DataTable object contains four objects: the DTRowSet object for row information, the DTColumnSet object for Column information, the DTCellSet object for cell information, and the DTCurCell object for current cell information.   The DTRowSet, DTColumnSet, and DTCellSet objects each contain other objects used to encapsulate information about a particular item in the set.  For example, the DTRowSet object contains the DTRow object which encapsulates information about a particular row.

In a file cabinet, access to a drawer is through the file cabinet and access to a file is through a drawer.  In the same way, access to DataTable objects is through the parent object.  For example, access to the DTRowSet object is through the DataTable object and access to a DTRow object is through the DTRowSet object.

The following diagram illustrates the DataTable object hierarchy.  The circles represent objects and the text to the left of the connecting lines specifies the properties used to retrieve the object.

The DataTable object hierarchy

Which DataTable Object Do I Use?

To determine which object to use, ask yourself what you want to affect.  The answer to this question will point you to the right object.

What do you want to affect?	Object
The entire DataTable.	DataTable
All DataTable rows.	DTRowSet
All DataTable columns.	DTColumnSet
All DataTable cells.	DTCellSet
The current cell (the cell with input focus).	DTCurCell
A particular row.	DTRow
A particular column.	DTColumn
A particular cell.	DTCell


Building a Visual Basic DataTable Application

This section describes how to build a DataTable application in Visual Basic.  It is assumed you are familiar with Visual Basic.  Please refer to your Visual Basic manuals for a more detailed explanation on the Visual Basic interface to controls.

Adding the DataTable OCX to a Visual Basic Project

To use the DataTable in Visual Basic, the DataTable OCX must be added to your project.  From the Tools menu, choose Custom Controls to invoke the Custom Controls dialog.

Adding the DataTable OCX  in Visual Basic

Select ProtoView DataTable Control from the Available Controls list box and press the OK button.  If  ProtoView DataTable Control is not visible in the list box, use the Browse button to locate and register the DataTable control.

The DataTable icon, [image], is now displayed in the Toolbox. The DataTable behaves like any other control.  The DataTable can be dragged from the Toolbox to a form, DataTable properties can be retrieved or set, and DataTable event procedures can be created.

Designing the DataTable in Visual Basic

To place a DataTable on a form, select the DataTable icon, [image], from the Toolbox.  Move the mouse cursor to the desired location on the form and press the left mouse button.  While holding the left mouse button down, drag the rectangle to the desired DataTable size.

To resize the DataTable move the mouse over one of the sizing handles.  When the mouse changes to a bi-directional arrow, hold the mouse button down and draw the border to the new desired size.

The DataTable is configured using the ProtoView DataTable Control Properties dialog.  This dialog is invoked by right clicking on the DataTable and selecting Properties... from the floating menu.  See The ProtoView DataTable Control Properties Dialog section for more information.

At design time the DataTable can be put into an active state by right clicking on the DataTable and selecting Edit from the floating menu.  Once in the active state, the DataTable border changes to a thick hatched border and the DataTable responds to user input.  The active state is useful to visually set the column widths.  To set column widths, move the mouse over the grid line separating the columns, press the left mouse button and while holding it down, drag the grid line to the desired width.  The active state also allows the programmer to test the DataTable behavior and appearance.  When the DataTable is in the active state, the ProtoView DataTable Control Properties dialog can be invoked by right clicking on the DataTable.

Accessing Properties and Methods in Visual Basic

To access a property in Visual Basic, use the object name followed by a "." followed by the property name.  The following example sets and retrieves the DataTable objects HorzGridLines property.

DataTbl1.HorzGridLines = True
HasGrid = DataTbl1.HorzGridLines

Accessing a method is the same as referencing a property.  Use the object name followed by a "." followed by the method name.  The following example calls the DataTable objects Reset  method.

DataTbl1.Reset

Creating DataTable Event Procedures

To attach code to a DataTable event, left double click on the DataTable control to invoke the Code window.  In the Procedure box, select the event to which you want to attach code.  Visual Basic generates the event procedure and places the cursor inside the new procedure.

Binding A DataTable to a Data Base

A DataTable is bound to a database by specifing a Data control in the DataSource property at design time using the Properties window.  (The DataSource property is not available at run time.)

A DataTable column is bound to a field in the Recordset by setting the DTColumn objects Bound property to TRUE and Name property to the field name.  This can be done at either design or run time.

The DataTable can create a column for each field in the Recordset at design time using the Auto Config to DB button found on the Columns tab page.  At run time, the DataTable can be automatically configured using the DataTable objects DBAutoConfig method.  When automatically configuring the DataTable, all previous column and row information is destroyed.


Building a Visual C++ DataTable Application

This section describes how to build a DataTable Application in Visual C++.

Enabling OCX Controls in Visual C++

To use the DataTable in a Visual C++ project, OCX controls must be enabled.  When AppWizard is creating a new project, one of the questions will be What OLE support would you like to include?.  Check the OLE controls check box.

AppWizard's dialog

Adding the DataTable OCX to the Component Gallery

To use the DataTable in a Visual C++ project, the DataTable OCX must be added to the Component Gallery.  This is accomplished by selecting Component from the Insert menu to invoke the Component Gallery dialog.

Adding the DataTable OCX to the Component Gallery

Choose the ProtoView DataTable Control icon from the Ole Controls tab page and press the Insert button.  (If the ProtoView DataTable Icon is not visible on the OLE Controls tab page, use the Customize button to locate and register the DataTable control. )  Pressing the Insert button will invoke the Confirm Classes dialog.

Adding the DataTable OCX to the Component Gallery

The Confirm Classes dialog allows the user to customize the OLE wrapper that is generated.  Press the OK button to insert the DataTable OLE control and generate the wrapper classes.

The DataTable icon, [image], is now displayed on the dialog editors toolbar.  The DataTable behaves like any other control.  It can be dragged from the dialog editors toolbar to a dialog, its properties can be retrieved or set, and methods can be called.  ClassWizard can also be used to assign a pointer to the DataTable and add event handlers.

Designing the DataTable in Visual C++

To place a DataTable on a dialog, select the DataTable icon, [image], from the dialog editors toolbox.  Move the mouse cursor to the desired location on the form and press the left mouse button.  While holding the left mouse button down, drag the rectangle to the desired DataTable size.

To resize the DataTable move the mouse over one of the sizing handles.  When the mouse changes to a bi-directional arrow, hold the mouse button down and draw the border to the new desired size.

The DataTable is configured using the ProtoView DataTable Control Properties dialog.  This dialog is invoked by right clicking on the DataTable and selecting Properties... from the floating menu.

At design time the DataTable can be put into an active state by right clicking on the DataTable and selecting ProtoView DataTable Control Object and then selecting Edit.  Once in the active state, the DataTable border changes to a thick hatched border and the DataTable responds to user input.  The active state is useful to visually set the column widths.  To set column widths, move the mouse over the grid line separating the columns, press the left mouse button and while holding it down, drag the grid line to the desired width.  The active state also allows the programmer to test the DataTable behavior and appearance.  When the DataTable is in the active state, the ProtoView DataTable Control Properties dialog can be invoked by right clicking on the DataTable.

Declaring the DataTable Control Pointer

To access DataTable member functions, use ClassWizard to declare a pointer to the DataTable control.   Invoke the ClassWizard and select the Member Variables tab page.  Select the class that contains the DataTable from the Class Name list box and select the id of the DataTable from the Control IDs list box.  Click on the Add Variable button to invoke the Add Member Variable dialog.

ClassWizard's Add Member Variable dialog

Enter the name of the DataTable control pointer in the Member Variable Name edit box.  The Category list box should already be set to Control and the Variable Type list box should be set to CDataTbl.   Press the OK button to have ClassWizard add a member variable for the DataTable control pointer.

DataTable Events Handlers

You can use ClassWizard to generate an event handler for the DataTable.  Invoke the ClassWizard and select the Message Maps tab page.

ClassWizards Message Maps tab page

Select the class that contains the DataTable from the Class Name list box and the id of the DataTable in the Object IDs list box.  This causes the DataTable events to be displayed in the Messages list box.  Choose the event to be handled from this list box and click the Add Function button.

This will present the Add Member Function dialog box.  Enter the Name of the function that will handle the event in the edit box and press OK.  The Message Maps tab page will come back into view and the Member Functions list box will now contain the new event handler.  Click OK to close the ClassWizard. ClassWizard will generate a template for the event handler.

Accessing Properties and Methods in Visual C++

Visual C++ generates two member functions for each property, one for retrieving and one for setting the property.  The retrieving member functions name is the property name with the prefix Get.  The setting member functions name is the property name with the prefix Set.  The following example retrieves and sets the DataTable property HorzGridLines.

BOOL bHasGridlines = m_dataTbl.GetHorzGridLines();
m_dataTbl.SetHorzGridLines (TRUE);

Visual C++ generates a member function for each method.  The member functions has the same name as the method.  The following example calls the DataTable objects Reset method.

BOOL bHasGridlines = m_dataTbl.Reset();

Adding the DataTable Constants File in Visual C++

Visual C++ needs to know how to resolve the constants used when accessing properties.  DataTable constants are defined in the header file "DTOCX.H".  Include DTOCX.H in files that access DataTable properties.

#include "DTOCX.H"

Passing Data to and from the DataTable in Visual C++

The DataTable uses the VARIANT type to pass data to and from the DataTable.

The VARIANT type is a tagged union used to store data of any type.   The VARIANT type supports the standard data types as well as CURRENCY and DATE.  Visual C++ encapsulates the VARIANT type in the COleVariant class, the CURRENCY type in the COleCurrency class, and DATE type in the COleDateTime classes. Please refer to your Visual C++ documentation for more information on VARIANT, COleVariant, COleCurrency, and COleDateTime.

The COleVariant class is very useful when storing data into the variant, but retrieving data from the variant is difficult.  The programmer is required to know the correct data type constant and data member name to extract the value. The COleVariant class becomes even more difficult to use when multiple pieces of data are passed using a variant array, for example when inserting a row of data.  In this case, the programmer is required to change the variant type, create a safe array, set a data member of the variant to the safe array, create a temporary variant, and then for each column set the value of the temporary variant and put the temporary variant into the safe array.

The DataTable has included a class, CDTData, designed to make passing data easier. The CDTData class is derived from the COleVariant class.   It contains member functions to create a variant array (CreateArray), store an item in a variant array (PutItem),  retrieve an item from a variant array (GetItem), and retrieve an item from a variant that is not an array (Get). This class can be found in the DTOCX.H header file.

The following example demonstrates how to retrieve a short value from the DataTable using the COleVariant class.

COleVarient var;
short data;
// retrieve the value in a cell.
var = m_dataTbl.GetCellSet().GetItem(0,0).GetValue();
// insure the value is the correct type
var.ChangeType(VT_I2);
// retrieve the value for the structure
data = var.iVal;

Compare this to following example which demonstrates how to retrieve a short value from the DataTable using the CDTData class.  Notice that the programmer no longer needs to know about the constant VT_I2 or the data member iVal.

CDTData var;
short data;
// retrieve the value in a cell.
var = m_dataTbl.GetCellSet().GetItem(0,0).GetValue();
// convert and retrieve an short integer value
var.Get (&data);

The usefulness of the CDTData class is shown when working with arrays.  The following example demonstrates the code required to insert a row with three columns using the COleVariant class.

COleVariant RowData;
COleVariant CellData;
SAFEARRAYBOUND bound;
long index;

bound.lLbound = 0;
bound.cElements =3;
RowData.vt = VT_ARRAY | VT_VARIANT;
RowData.parray = SafeArrayCreate(VT_VARIANT, 1, &bound);
CellData = Smith;
index=0;
SafeArrayPutElement(parray, &index, CellData);
CellData = 2500.00f;
index=1;
SafeArrayPutElement(parray, &index, CellData);
CellData = 1L;
index=2;
SafeArrayPutElement(parray, &index, CellData);
m_dataTbl.GetRowSet().Add(dtAfterLast, RowData);

Using the CDTData class, the above code can be condensed to the following.

CDTData RowData;
RowData.CreateArray(3);
RowData.PutItem("Smith", 0);
RowData.PutItem(2500.00f, 1);
RowData.PutItem(1L, 2);
m_dataTbl.GetRowSet().Add(dtAfterLast, RowData);


Building a Delphi DataTable Application

This section describes how to build a DataTable application in Delphi.  It is assumed you are familiar with Borlands Delphi.  Please refer to your Delphi manuals for a more detailed explanation on the Delphis interface to controls.

Installing the DataTable in Borlands Delphi

To use the DataTable OCX control in Delphi, you must first add the OCX to the component library.  This is accomplished by selecting the Component | Install ... menu item to invoke the Install Components dialog.

Installing components  in Delphi

Press the OCX... button to invoke the Import OLE Control dialog.

Installing the DataTable OCX in Delphi

Choose the ProtoView DataTable Control from the Registered controls list box.  Specify the unit file name and the Component palette page where you want the DataTable icon to appear and press the OK button.  Press the OK button again to close the Install Components dialog.

The DataTable behaves like any other control.  It can be selected from the Toolbox and drawn on a form, properties can be set and retrieved, and event procedures can be created.

Designing the DataTable in Delphi

To place a DataTable on a form, select the DataTable icon, [image], from the Component palette page you chose while installing the DataTable.  Move the mouse cursor to the desired location on the form and press the left mouse button.  While holding the left mouse button down, drag the rectangle to the desired DataTable size.

To resize the DataTable move the mouse over one of the sizing boxes.  When the mouse changes to a bi-directional arrow, hold the mouse button down and draw the border to the new desired size.

The DataTable is configures using the ProtoView DataTable control Properties dialog.  This dialog is invoked by right clicking on the DataTable and selecting Properties... from the floating menu.  See The ProtoView DataTable Control Properties Dialog section for more information.

Accessing Properties and Methods in Delphi

To access a  property at run time, use the DataTable object name followed by a "." followed by the property name.  The following example sets and retrieves the DataTable objects HorzGridLines property.

DataTbl1.HorzGridLines := TRUE;
HasGridLines := DataTbl1.HorzGridLines;

Accessing a method is the same as accessing a property.  Use the object name followed by a . followed by the method name.  The following example calls the DataTable objects Reset method.

DataTbl1.Reset;

Creating DataTable Event Handlers in Delphi

You can use the Object Inspector to generate an event handler for the DataTable.  From the Events tab page of the Object Inspector, select the event you want, and double click on the Value column.  Delphi generates the event handler in the Code Editor and places the cursor inside the generated event handler.

Adding the DataTable Constants Unit File

The DataTable defines constants in the DTOcx unit.  Any program or unit that uses any of the DataTable constants, must include the DTOCX unit in there uses clause.

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  OleCtrls, DATATBL, StdCtrls, DTOcx;

The file DTOCX.PAS must be found in your search path.  The search path is specified on the Directories/Conditionals tab page of the Project Options dialog.  (The Project Options dialog is invoked by choosing the Options | Project menu item.)

Passing Data to and from the DataTable in Delphi

The DataTable passes information using the Variant data type.  When the DataTable must pass several pieces of information, for example, when updating a row of data, the DataTable uses a variant array.

Delphi includes the following variant array support procedures and functions: VarArrayCreate, VarArrayOf, VarArrayDimCount, VarArrayLowBound, VarArrayHighBound, VarArrayLock, VarArrayUnlock, and VarIsArray.  Please see your Delphi documentation for more information on variant arrays.


The ProtoView DataTable Control Properties Dialog

The ProtoView DataTable Control Properties dialog is used to configure the DataTable.  This dialog is invoked by right clicking on the DataTable at design time and selecting Properties from the floating menu.

The ProtoView DataTable Control Properties dialog is a tabbed dialog containing a separate page for configuring the following: general information, columns, rows, headings and labels, the current cell, user selection, sorting, colors, and fonts.

The General Tab Page

The General tab page is used to specify overall DataTable information.

The General tab page

The General tab page contains controls used to set the following information: border, horizontal scroll bar, vertical scroll bar, three dimensional effect, drop down style, virtual memory type, horizontal grid lines, vertical grid lines, whether to fire the PaintCell event, horizontal window splitting, height of the top pane, vertical window splitting, and the width of the left pane.

Border

The Border combo box specifies the type of border drawn around the  DataTable.  The available choices are None and Fixed Single.  If None is chosen, no border is drawn.  If Fixed Single is chosen, a fixed single line border is drawn around the DataTable.

The Border combo box represents the DataTable objects Border property.

Horz Scroll Bar

The Horz Scroll Bar combo box specifies when a horizontal scroll bar is displayed. The available choices are None, Automatic, and Always Visible.  If None is chosen, the DataTable never displays a horizontal scroll bar. If Automatic is chosen, the DataTable displays a horizontal scroll bar only when the width of all of the columns is greater then the DataTable window width.  If  Always Visible is chosen, a horizontal scroll bar is always displayed.

The Horz Scroll Bar combo box represents the DataTable objects HorzScrollBar property.

Vert Scroll Bar

The Vert Scroll Bar combo box specifies when a vertical scroll bar is displayed. The available choices are None, Automatic, and Always Visible.  If None is chosen, the DataTable never displays a vertical scroll bar. If Automatic is chosen, the DataTable displays a vertical scroll bar only when the height of  all of the DataTable rows is greater then the DataTable window height.  If  Always Visible is chosen, a vertical scroll bar is always displayed.

The Vert Scroll Bar combo box represents the DataTable objects VertScrollBar property.

ThreeD Effect

The ThreeD Effect combo box specifies an optional three dimensional effect drawn around the DataTable.  The following choices are available: None, Heavy Indent, Shadow, Outdent, Indent frame, and Light Indent.

The ThreeD Effect combo box  represents the DataTable objects Appearance property.

Drop Down

The Drop Down combo box specifies an optional drop down feature.  The choices are No Drop Down, Drop Down and Auto Drop Down.  Selecting "No Drop Down" disables the DataTable drop down feature.  Selecting "Drop Down" allows the DataTable to be dropped down or closed up by pressing the ALT + down arrow keys.  Selecting "Auto Drop Down" not only allows the DataTable to drop down or close up using the ALT + down arrow, but adds the additional capability of automatically dropping down and closing up when the DataTable gains and loses focus.

The Drop Down combo box represents the DataTable objects DropDownType property.

Virtual Memory

The Virtual Memory combo box specifies the virtual memory mode. The available choices are None, Indexed, and User Defined.  Selecting None disables the virtual memory feature.  Selecting Indexed enables the virtual memory feature with indexed keys.  Selecting User Defined enables the virtual memory feature with user defined keys.

The Virtual Memory combo box represents the DataTable objects VirtualMemType property.

Horz Grid Lines

The Horz Grid lines check box enables horizontal grid lines to be drawn between rows.

The Horz Grid lines check box represents the DataTable objects HorzGridLines property.

Vert Grid Lines

The Vert Grid lines check box enables vertical grid lines to be drawn between columns.

The Vert Grid lines check box represents the DataTable objects VertGridLines property.

Split Window Horz

The Split Window Horz check box enables the DataTable window to be split horizontally.

The Split Window Horz check box represents the DataTable objects HorzSplitPane property.

Top Pane Height

The Top Pane Heightedit box is used to set the height of the top pane.  It is only enabled when horizontal window splitting is enabled.  The height is expressed in the scale units of the DataTable's container.  Specify -1 to set the height to the maximum size.

The Top Pane Height edit box represents the DataTable objects TopPaneHeight property.

Split Window Vert

The Split Window Vert check box enables the DataTable window to be split vertically.  The Top Pane Height edit box is used to set the top pane height.  It is only enabled when vertical window splitting is enabled.  The height is expressed in the scale units of the DataTable's container.

The Split Window Vert check box represents the DataTable objects VertSplitPane property.

LF Pane Width

The LF Pane Width edit box is used to set the left pane width.  It is only enabled when vertical window splitting is enabled.  The width is expressed in the scale units of the DataTable's container.  Specify -1 to set the width to the maximum size.

The LF Pane Width edit box represents the DataTable objects LeftPaneWidth property.

Paint Cell Event

The Paint Cell Event check box enables the PaintCell  event  to be fired.  This event is needed when the DataTable parent wants to paint a DataTable cell.

The Paint Cell Event check box represents the DataTable objects AllowPaintCellEvent property.

The Columns Tab Page

The Column tab page is used to customize the appearance and behavior of the DataTable columns.

The Columns tab page

The Columns tab page contains controls for setting the ability to resize columns, whether columns with lists show the list arrow, and the number of items shown in the drop down list box. The Columns tab page also contains a DataTable control used to create and customize individual columns.

Column Resizing

The Column Resizing check box enables columns to be resized by the user at run time.  When the user moves the mouse over the column grid line, the cursor will change and the user can drag the column grid line to the desired column width.  Column resizing can be overridden for a particular column using the Column Configuration tab page.

The Column Resizing check box represent the DTColumnSet objects AllowResize property.

Hide List Arrow

The Hide List Arrow check box is used to specify whether the drop down arrow associated with a drop down column is shown only on the current cell.

The Hide List Arrow edit box represents the DTColumnSet objects HideListArrow property.

Num List Items

The Num List Items edit box is used to specify the number of items that will appear in a drop down column list.

The Num List Items edit box represents the DTColumnSet objects NumListItems property.

Auto Config to DB

The Auto Config to DB button is enabled when the DataTable DataSource property has been set.  Pressing this button causes the DataTable to delete any existing columns and automatically create a new column for each field in the Recordset.

The Auto Config to DB button simulates the DataTable objects DBAutoConfig method.

Customizing Columns

The Columns tab page uses a DataTable control to create and customize individual columns.  Each row in this DataTable control represents a column being configured.  To avoid confusion, a column in the DataTable used for designing will be called a field and a column being configured will be called a column.

There are two ways to insert a new column.  A new column is inserted prior to the column with the input focus by pressing the insert key.  A new column can also be added to the end of the table by pressing the down arrow when the input focus is on the last column.

To delete a column, move the input focus to the column you wish to delete and press the delete key.

Click on a field heading to lock a field.  The locked field will move to the left of the table and remain visible when the table is scrolled horizontally.  The picture in the Columns tab page description shows the Heading field locked.

For each column the following information can be set: data type, data length, display width, heading, format, list items, default value, symbolic name, ability to edit, ability to adjust the width, locked state, hidden state, ability to overwrite, heading alignment, data alignment, and the editing styles of automatic horizontal scroll, automatic vertical scroll, uppercase, lowercase, want returns, multi-line.

Type

 The Type field is a drop down list box used to select the data type for the current column.  Selecting a data type automatically sets the Length field to the length of the new data type.  If the length of the new type is variable, the data length is set to zero.

The Type field represents the DTColumn objects DataType property.

Length

The Length field is used to specify the number of bytes needed to store the data.  The length can only be edited on a column which has a variable length data type, such as strings.

The Length field represents the DTColumn objects DataLen property.

Width

The Width field is used to specify the width of the column seen by the user.  This width is expressed in the scale units of the DataTable's container.

The Width field represents the DTColumn objects Width property.

Heading

The Heading field is used to specify the custom heading text for the column.  This field is only visible if "Custom" column headings was chosen as the column heading type on the Headings\Labels tab page.  Use CTRL+ENTER to move to the next line when entering a multiple line heading.

The Heading field represents the DTColumn objects Heading property.

Format

The Format field is a drop down combo box used to specify the column's formatting string.  The drop-down combo box contains some popular predefined formatting strings.

The Format field represents the DTColumn objects Format property.

List

The List field is used to specify the items in a drop down list column.  By assigning list items, the column becomes a drop down list box.  Specify the first item and then press CTRL+ENTER to move to the next line and enter additional items.

The List field represents the DTColumn objects List property.

Default Val

The Default Val field is used to specify a default value for the column when an empty row is inserted into the DataTable.

The Default Val field represents the DTColumn objects DefVal property.

Bound

The Bound field is a checkbox which when checked, enables the column to be bound to a field in the Recordset.  The field the column is bound to is specified by the Symbolic Name.

The Bound field represents the DTColumn objects Bound property.

Symbolic Name

When working with an unbound column, the Symbolic Name field specifies a symbolic name string used for referencing the column in a program.  Assigning a symbolic name is useful when the sequential column index can be changed at run time.  For example, if the user is allowed to insert, delete or move columns, the programmer may not know what the index number of a column is.

When working with a bound column, the Symbolic Name field specifies which field in the Recordset the column is bound to.  If the DataTable objects DataSource property is set to a Data control, the Symbolic Name field becomes a drop down list of  available field  names.

The Symbolic Name field represents the DTColumn objects Name property.

Editable

The Editable field is a drop down list box which specifies if the column can be edited.  The available choices are: Default, Editable, and Protected.  If Default is specified, the column is editable if the Editable check box on the Current Cell tab page was checked.

The Editable field represents the DTColumn objects DataEdit property.

Width Adj

The Width Adj field is a drop down list box used to specify whether the user can resize the column.  The available choices are: Default, Fixed, and Adjustable.  If Default is specified, the column is resizable if the Column Resizing check box on the Columns Tab page was checked.

The Width Adj field represents the DTColumn objects Resize property.

Locked

The Locked field is check box which when checked, causes the column to be locked.  A locked column is moved to the far left side of the DataTable window and does not scroll horizontally when the DataTable window scrolls horizontally.  A locked column does scroll vertically.

The Locked field represents the DTColumn objects Locked property.

Hidden

The Hidden field is a check box which when checked, causes the column to be hidden.  Hidden columns are useful when a row needs to be associated with some data value that isn't visible or meaningful to the user of a DataTable.  For example, the id of a record or row of data in a database.

The Hidden field represents the DTColumn objects Hidden  property.

Overwrite

The Overwrite field is check box which when checked, allows the text of the column to overwrite adjoining columns when a cell in the column has the input focus.

The Overwrite field represents the DTColumn objects OverWrite property.

Head Align

The Head Align field is a drop down list box used to specify the alignment of the column heading text.  The available choices are Left, Center, and Right.  This field is not visible if  None was specified as the column heading type on the Headings\Labels tab page.

The Head Align field represents the DTColumn objects HeadAlign property.

Data Align

The Data Align field is a drop down list box which specifies the alignment of the data for the column. The available choices are Left, Center, and Right.

The Data Align field represents the DTColumn objects DataAlign property.

AutoHScrl

The AutoHScrl field is a check box used to customize column editing. When the AutoHScrol check box is checked, the DataTable automatically scrolls the text horizontally when the user types a character at the end of the line while editing.

The AutoHScrl field represents the DTColumn objects EditAutoHScroll property.

AutoVScrl

The AutoVScrl field is a check box used to customize column editing.  When the AutoVScrl check box is checked, the DataTable automatically scrolls the text up a page when the user attempts to go to the next line while editing. This style is only used on columns which have the MultiLine field checked.

The AutoVScrl field represents the DTColumn objects EditAutoVScroll property.

Lowercase

The Lowercase field is a check box used to customize column editing.  When the Lowercase check box is checked, the DataTable converts all characters to lowercase as they are typed while editing.

The Lowercase field represents the DTColumn objects EditLowercase property.

Uppercase

The Uppercase field is a check box used to customize column editing.  When the Uppercase check box is checked, the DataTable converts all characters to uppercase as they are typed while editing.

The Uppercase field represents the DTColumn objects EditUppercase property.

MultiLine

The MultiLine field is a check box used to customize column editing.  When the MultiLine check box is checked, the DataTable allows multiple lines to be entered while editing.

The CTRL+ENTER key is used to move to the next line by default.  The ENTER key is used if the WantRet check box is checked.

When moving to the next row, either the AutoVScrl field must be checked or the row must have enough height left to accommodate the new line.

The MultiLine field represents the DTColumn objects EditMultiLine property.

WantRet

The WantRet field is a check box used to customize column editing.  When the WantRet check box is checked, the DataTable allows the ENTER key to be used to move to the next line while editing.  If this field is not checked, CTRL+ENTER is used to move to the next line.  This style is only used on columns which have the MultiLine field checked.

The WantRet field represents the DTColumn objects EditWantReturn property.

The Rows Tab Page

The Rows tab page is used to customize the appearance and behavior of the DataTable rows.

The Rows tab page

Row Resizing

The Row Resizing check box enables rows to be resized by the user at run time.  When the user moves the mouse over the row grid line, the cursor will change and the user can drag the row grid line to the desired row height.  Row resizing can be overridden for a particular row with the DTRow objects Resize property.

The Row Resizing check box represent the DTRowSet objects AllowResize property.

Auto Row Insert

The Auto Row Insert check box enables an empty row to be automatically inserted at the end of the table when the user attempts to move to a row after the last row.

The user may attempt to move to the next row by either pressing the down arrow on the last row or pressing the next cell key on the last cell in the table.  The next cell key is either the TAB or CTRL+TAB key.  (Which key is used to move to the next cell is set using the Current Cell tab page.)

An empty row is inserted only if the last row is not empty or the table is empty.

The Auto Row Insert check box enables the DTRowSet objects AllowAutoRowInsert property.

Trap Insert Key

The Trap Insert Key check box enables the insert key to be used to insert an empty row prior to the current row.

The Trap Insert Key check box represents the DTRowSet objects TrapInsertKey property.

Trap Delete Key

The Trap Delete Key check box enables the delete key to be used to delete the current row.

The Trap Delete Key check box represents the DTRowSet objects TrapDeleteKey property.

Initial Row Count

The Initial Row Count edit box is used to set a number of empty rows the table will be created with.

The Initial Row Count edit box represents the DTRowSet objects Count property.

Row Height

The Row Height edit box is used to set the height of the rows.  If zero is specified, a height compatible with the row font is used.

The height of a particular row can be set at run time using the DTRow objects Height property.

The Row Height edit box represents the DTRowSet objects Height property.

Vertical Alignment

The Vertical Alignment combo box sets the vertical alignment of the row data within a row.  The available choices are Top, Center, and Bottom.

The Vertical Alignment combo box represents the DTRowSet objects VertAlign property.

The Headings \ Labels Tab Page

The Headings\Labels tab page is used to customize the appearance and behavior of the row labels and column headings.

The Headings\Labels tab page

This dialog contains two group boxes. The Column Headings group box customizes the column headings and the Row Labels group box customizes the row labels.

Column Headings

The Column Headings group box is used to customize the appearance and behavior of the column heading row.

The Type combo box specifies the type of column headings used.  The available choices are None, Numbers, Letters, and Custom.  Choosing "Numbers"  causes column headings to be numbered from 1 up.  Choosing "Letters" causes column headings to be lettered from A up.  If "Custom" is chosen, column headings contain the text specified for each column using the Column tab page.  The Type combo box represents the DTRowSet objects HeadingType property.

The Height edit box is used to enter the column heading row height.  Enter "0" to use a default height that is compatible with the DataTable font.  The DataTable will respond by changing the 0 to the actual height used.  The column heading height is expressed in the scale units of the DataTable's container.  The Height edit box represents the DTRow objects Height property for the column headings row.

The Resizing combo box specifies if the column headings row height can be resized. The available choices are Fixed, Adjustable, and Default.  If "Fixed" is chosen, the column heading row height can not be resized.  If "Adjustable" is chosen, the column heading row height can be resized.  Selecting "Default" specifies that the column heading row height is resizable if the Row Resizing check box on the Rows tab page is checked.  This combo box represents the DTRow objects Resize property for the column headings row.

Row Labels

The Row Labels group box is used to customize the appearance and behavior of the row labels column.

The Type combo box is used to specify the type of row labels used.  The available choices are None, Custom, and Numbers.  If "Numbers" is chosen, rows are labeled with sequential row numbers starting from 1.  If "Buttons" is chosen, rows are labeled with an empty button.  The row label text for a specific row can be set at run time using the DTRow objects Label property.  The Type combo box represents the DTColumnSet objects LabelType property.

The Width edit box is used to specify the width of the row labels column.  The width is specified in the scale units of the DataTable's container.  This edit box represents the DTColumn objects Width property for the row labels column.

The Alignment combo box is used to specify the alignment of the row label text.  The choices available are: Left, Center, and Right. This combo box represents the DTColumn objects DataAlign property for the row labels column.

The Resizing combo box is used to specify if the row labels column width can be resized. The available choices are Fixed, Adjustable, and Default.  If "Fixed" is chosen, the row labels column width can not be resized.  If "Adjustable" is chosen, the row labels column width can be resized.  Selecting "Default" specifies that the row labels column width is resizable if the Column Resizing check box on the Columns tab page is checked.  This combo box represents the DTColumn objects Resize property for the row labels column.

The Current Cell Tab Page

The Current Cell tab page is used to customize the appearance and behavior of the current cell.

The Current Cell tab page

The Current Cell tab page contains controls used to set the following:  whether the current cell is editable, use of the tab key, direction of the next cell, and a group box used to set additional ways for the user to end edit mode.

Editable

The Editable check box enables the current cell to be edited by the user.  The ability to edit cells of a particular column can be overridden using the Column tab page.

The Editable check box represents the DTCurCell objects AllowCellEdit property.

Tab To Next Cell

The Tab To Next Cell check box is used to change the key that is used to move to the next cell.  By default, the control tab key is used to move to the next cell and the tab key is used to move to the next control.  Selecting this check box causes the tab key to be used to move to the next cell and the control tab key to move to the next control.

The Tab To Next Cell check box represents the DTCurCell objects TabToNextCell property.

Move Column Major

The Move Column Major check box is used to change the direction the DataTable moves in when moving to the next cell.  The default movement, "Row Major", moves to the next column within a row before moving to the next row.  For example, move from row 1, column 1 to row 1, column 2 .  Selecting this check box causes the DataTable to move "Column Major".  That is  move to the next row before moving to the next column.  For example, move from row 1, column 1 to row 2, column 1.

The Move Column Major check box represents the DTCurCell objects MoveColMajor property.

End Edit With

The End Edit With group box specifies which additional keys can be used to end edit mode.  The left and right arrows, up and down arrows, tab key, control tab key and mouse can be used to end edit.

This group box sets the DTCurCell objects EndEditLfRtArrows, EndEditUpDnArrows, EndEditTab, EndEditCtrlTab, and EndEditClick properties.

The Selection Tab Page

The Selection tab page is used to specify the type of user selection allowed.

The Selection tab page

This dialog contains combo boxes to set the type of row, column and block selection.

Row Selection

The RowSelection combo box specifies the type of row selection allowed.  The available choices are None, Single, and Multiple.  If None is chosen, rows can not be selected.  If Single is chosen, only one row can be selected at a time and the selected row is always the current row.  If Multiple selection is chosen, multiple rows can be selected at a  time.  This combo box represents the DTRowSet objects SelectType property.

Column Selection

The ColumnSelection  combo box specifies the type of column selection allowed. The available choices are None, Single, and Multiple.  If None is chosen, columns can not be selected.  If Single is chosen, only one column can be selected at a time and the selected column is always the current column.  If Multiple selection is chosen, multiple columns can be selected at a time.  This combo box represents the DTColumnSet objects SelectType property.

Block Selection

The Block Selection  combo box specifies the type of block selection allowed. The available choices are None and Single.  If None is chosen, blocks can not be selected.  If Single is chosen, only one block can be selected at a time and the selected block always contains the current cell. This combo box represents the DTCellSet objects SelectType property.

The Sorting Tab Page

The Sorting tab page is used to specify the DataTable sorting information.

The Sorting tab page

The Sorting tab page contains a group box for each of the three sort keys.  The Secondary Sort Key group box is disabled until a column is chosen for the primary sort key. Likewise, the Tertiary Sort Key group box is disabled until a column is entered for secondary sort key.

For each sort key, specify the column index, sorting direction and whether the sort is case insensitive.  To disable sorting, choose None from the combo box.

This tab page sets the DTColumnSet objects SortKey, SortAsc, and SortCaseI properties.

The Colors Tab Page

The Colors tab page is used to specify the colors used for the DataTable.

The Colors tab page

The Object combo box is used to specify which object the color is being set for.

The Property Name combo box is used to specify which property the color is being set for.

The Color combo box is used to specify the color to assign.  If "Default" is chosen, a default color is assigned.  If "Palette Color" is chosen, the color is indicated by the color buttons on the right of the tab page.

The Font Tab Page

The Font tab page is used to specify the font used for the DataTable.

The Font tab page

The Object combo box is used to specify which object to set the font for.


The DataTable User Interface

The DataTable comes with predefined keyboard and mouse behavior.   This behavior is consistent with the behavior of other Windows controls whenever possible.

The Keyboard Interface

The following table describes the DataTable keyboard user interface.

Key	Behavior
Up	Move focus up one cell in the current pane
Down	Move focus down one cell in the current pane.
Right	Move focus right one cell in the current pane
Left	Move focus left one cell in the current pane
PgUp	Scroll up one page (full window pane)
PgDn	Scroll down one page (full window pane)
Home	Go to first column of the current row in the current pane
End	Go to last column of the current row in the current pane
CTRL+Up	Go to top visible row in the current pane
CTRL+Down	Go to bottom visible row in the current pane
CTRL+Right	Go to right most visible column in the current pane
CTRL+Left	Go to left most visible column in the current pane
CTRL+PgUp	Scroll left one page (full window pane)
CTRL+PgDn	Scroll right one page (full window pane)
CTRL+Home	Go to top left cell in the current pane
CTRL+End	Go to bottom right cell in the current pane
SHIFT+Space	Toggle selection of current row if multiple row selection is enabled
CTRL+Space	Toggle selection of current column if multiple column selection is enabled
SHIFT+Up	Extends selection toggle up if multiple row selection is enabled
SHIFT+Down	Extends selection toggle down if multiple row selection is enabled
SHIFT+Right	Extends selection toggle right if multiple column selection is enabled
SHIFT+Left	Extends selection toggle left if multiple column selection is enabled
F2	Edit current cell (can be set)
F6	Move to the next pane
SHIFT+F6	Move to the previous pane
Enter	End cell editing (can be set)
Esc	Abort cell editing (can be set)
SHIFT+CTRL+Tab	Move to the previous cell in the current pane
CTRL+Tab	Move to the next cell in the current pane
Other ASCII	Entered into the current cell if the current cell is editable

The DataTable fires events as the user presses and releases keys when the DataTable has the focus.  The DataTable fires the stock events KeyDown, KeyPress, and KeyUp when the DataTable is not in edit mode, and fires similar events EditKeyDown, EditKeyPress, and EditKeyUp when the DataTable is in edit mode.

Changing the Keyboard Interface

The insert key can be enabled to insert an empty row prior to the current row. To enable this feature at design time, use the Trap Insert Key checkbox found on the Rows tab page.  At run time, use the DTRowSet objects TrapInsertKey property.

The delete key can be enabled to delete the current row.  To enable this feature at design time, use the Trap Delete Key  checkbox found on the Rows tab page.  At run time, use the DTRowSet objects TrapDeleteKey property.

By default, the tab key moves to the next control and the control tab key moves to the next cell.  This can be switched to allow the tab key to move to the next cell and the control tab key to move to the next control. To enable this feature at design time, use the Tab to Next Cell checkbox found on the current Cell tab page.  At run time, use the DTCurCell objects TabToNextCell property.

The keys used to begin, end and abort editing can be set using the DTCurCell objects KeyForBeginEdit, KeyForEndEdit, and KeyForAbortEdit properties.

User Interface when using Window Splitting

The input focus moves to the next pane by pressing the F6 key and the previous pane with the shift F6 key.

As the user uses the keyboard to move the current cell, the current cell will always remain in the current pane (i.e. the current cell can not jump over the window splitter bars).  For example, pressing the right arrow on the last column of the left pane will not cause the current pane to switch to the right pane.

User Interface to Drop Down and Auto Drop Down Tables

A drop down table is dropped down or closed up by pressing the ALT+ down arrow keys.  An auto drop down table not only allows the table to drop down or close up using the ALT+down arrow keys, but has the additional capability of automatically dropping down or closing up when the DataTable gains or loses focus.

The DataTable fires the DropDown event when the DataTable dropped down status changes.

User Interface to Columns with Drop Down Combo boxes and List boxes

A column combo box or list box is toggled between being dropped down and closed up by pressing any of the following keys: F4 , ALT+Up arrow, and ALT+Down arrow.

The DataTable fires the ComboDropDn and ComboCloseUp events when the list box is dropped down and closed up.

User Interface to Check boxes

A check box is toggled by pressing the space bar when the current cell is a check box.  Pressing the left mouse button on a check box also toggles the state of the check box.

User Interface to Clipboard Support

The DataTable allows the user to cut, copy and paste information to the clipboard.  The DataTable information is stored and retrieved in a specific format where the columns are separated by the tab character and rows are separated by a new line character.

Pressing CTRL+X cuts the currently selected rows or columns to the clipboard.  The currently selected data is set to zero.

Pressing CTRL+C copies the currently selected rows or columns to the clipboard.  The currently selected data remains the same.

Pressing CTRL+V pastes the clipboard information into the DataTable.  The information is copied starting at the current cell.

Before a cut, the DataTable fires the BeforeCut event, before a copy the BeforeCopy event is fired and before a paste the BeforePaste event is fired.  These clipboard events pass one parameter, the Status parameter, which when set to non-zero enables the clipboard operation to be canceled.

Mouse User Interface

The following table describes the mouse user interface.

Mouse Action	Location	Behavior
Click	Cell	Selects cell
Click	Row button	Toggles row selection if row selection is enabled
Click	Column Heading	Toggles column selection if column selection is enabled
SHIFT+Click	Cell	Toggles row selection if row selection is enabled
SHIFT+Click	Row button	Toggles row selection if row selection is enabled
CTRL+Click	Cell	Toggles column selection if column selection is enabled
CTRL+Click	Column Heading	Toggles column selection if column selection is enabled
Drag	Cell	Extends either row or column selection depending  if row or column selection is enabled
Drag	Row button	Extends row selection if row selection is enabled
Drag	Column Heading	Extends column selection if column selection is enabled

The DataTable fires the following mouse events: LfClick with a left click, RtClick with a right click, LfDblClick with a left double click, and RtDblClick with a right double click.  These events pass a constant describing where the clicked occurred, the pane, row, and column index of where the click occurred, and a Status parameter which when set to non-zero enables the click to be ignored.

The DataTable also fires the stock events MouseUp and MouseDown when the user presses and releases a mouse button, and MouseMove when the mouse is moved over the DataTable.


Tutorials


Visual Basic Example

The following Visual Basic example will  demonstrate how to design a DataTable, insert data into the table, and how to write an event procedure.

Create a New Visual Basic Project

Start a new project by choosing New Project from the File menu.

Add the DataTable OCX to the project.  From the Tools menu, choose Custom Controls to invoke the Custom Controls dialog.  Select ProtoView DataTable Control from the Available Controls list box and press the OK button.  If  ProtoView DataTable Control is not visible in the list box, use the Browse button to locate and register the DataTable control.

The DataTable icon, [image], will now appear in the Toolbox.

Design the DataTable

Select the DataTable icon, [image],  from the Toolbox and draw the DataTable on the form.  Resize the DataTable so that it takes up most of the form.

Right click on the DataTable and choose Properties... from the floating menu.  Use the Columns tab page to configure the three columns.

Change the existing columns Type to string, Len to 30, and Heading to Last Name.  When setting the column heading, separate Last and Name with  CTRL+ENTER so that the heading takes up two lines.

Press the down arrow to insert another column.  Set the Type to single float, the Heading to Income, the Format to $#,##0.00 and the Def Val to 30000.

Press the down arrow again to insert the last column.  Set the Type to std checkbox and the Heading to Insured.

Configuring the DataTable columns in Visual Basic

Press the OK button when you are done configuring the last column.

The column widths can now be set visually.  Right click on the DataTable and select Edit from the floating menu.  The DataTable border will change to a thick hatched border to show that it is in edit mode.  Move the mouse over the grid line that separates the first and second column.  The cursor will change to a resizing cursor.  Press the left mouse button and, while holding the button, drag the grid line to the desired width.  Repeat this for the other two columns.

Run the program now to see the following output:

Initial output of Visual Basic Tutor1 example

Our DataTable already has a lot of functionality.  Notice that when new rows are inserted, the Income column is initialized to the default value. Press the insert key to insert new rows.  Press the delete key to delete the row with the input focus.  Edit the cells by setting the focus on a cell and typing in the new value.  Resize rows and columns by placing the mouse over the grid lines, pressing the left mouse button and dragging the grid line to the new size.

Add DataTable Data

Most applications will want to load their own data into the DataTable.  We will now demonstrate how to insert data into the DataTable.

Add a button to the form.  Double click on the button to add an event procedure to the Click event.

First, delete all the current row information.  This is done by calling the DTRowSet objects Reset method.

Datatbl1.RowSet.Reset

Next, create a variant array to hold the row information.  Since there are three columns, this array should have three items.  Set each item in the variant array to the data desired.  The first element of the array should contain the data for the first column, the second item in the array should contain the data for the second column and so on.

Dim Info(0 To 2) As Variant
Info(0) = "Smith"
Info(1) = "25000"
Info(2) = True

Finally, add the new row using the DTRowSet objects Add method.  This method takes two parameters: the location to insert the new row and the new rows data.  Specify that the new row is to be inserted to be inserted at the end of the table by using the constant dtAfterLast.  The new rows data is the variant array that was previously created.

Datatbl1.RowSet.Add dtAfterLast, Info

The entire click procedure is shown below.

Private Sub Command1_Click()
Dim Info(0 To 2) As Variant

Delete all current row information
Datatbl1.RowSet.Reset

  Set up the row information
Info(0) = "Smith"
Info(1) = "25000"
Info(2) = True

Add the new row after the last row
Datatbl1.RowSet.Add dtAfterLast, Info
End Private Sub

Run the program and press on the new button to see the following output.

Output of Visual Basic Tutor1 after pressing the Command1 button

Add an Event Procedure

Next we are going to use the LfClick event to alternate between hiding and showing the Income column when the user clicks on the top left corner button.

Invoke the Code window by double left clicking on the DataTable.  Choose LfClick from the Procedure list box.

First determine if the click was on the corner button.  The DataTable passes the click positions row and column index to the LfClick event.  If the row is the headings row (defined as dtHeadingsRow) and the column is the labels column (defined as dtLabelsColumn), the click was on the corner button.

If (Row = dtHeadingsRow And Column = dtLabelsColumn) Then
End If

If the click is on the corner button, we want to toggle whether the Income column is visible.  Since we are affecting a column, we first need to retrieve the DTColumn object for the Income column.  A DTColumn object is retrieved using the DTColumnSet objects Item property.  The Item property takes one parameter; the index of the column to return.  Since the Income column is the second column and columns are indexed starting at zero, specify a value of 1.

Dim IncomeCol As DTColumn
Set IncomeCol = Datatbl1.ColumnSet.Item(1)

Since Item is the default property, the property name need not be specified.  The above code can be shortened to the following.

Dim IncomeCol As DTColumn
Set IncomeCol = Datatbl1.ColumnSet(1)

Once we have the Income columns DTColumn object, we can access the Hidden property.  Toggle the Hidden property by setting the Hidden property to the logical not of the current value of the Hidden property.

IncomeCol.Hidden = Not IncomeCol.Hidden

The entire LfClick event procedure is shown below.

Private Sub Datatbl1_LfClick(ByVal Pane As Integer, ByVal Row As Long,
ByVal Column As Long, ByVal ClickPos As Long, Status As Long)
Dim IncomeCol As DTColumn

' if click was on the corner button
If (Row = dtHeadingsRow And Column = dtLabelsColumn) Then
   ' Determine if the income column (index 1) hidden state
   Set IncomeCol = Datatbl1.ColumnSet(1)
   ' toggle the income column's hidden state
   IncomeCol.Hidden = Not IncomeCol.Hidden
End If
End Sub

Run the program now.  The program output will appear the same but by clicking on the corner button, the Income column will disappear and reappear.


Visual Basic Bound Example

The following Visual Basic example will demonstrate how to bind a DataTable to a data base.

Create a New Visual Basic Project

Start a new project by choosing New Project from the File menu.

Add the DataTable OCX to the project.  From the Tools menu, choose Custom Controls to invoke the Custom Controls dialog.  Select ProtoView DataTable Control from the Available Controls list box and press the OK button.  If  ProtoView DataTable Control is not visible in the list box, use the Browse button to locate and register the DataTable control.

The DataTable icon, [image], will now appear in the Toolbox.

Design the DataTable

Place a Visual Basic data control on the form.  Set the DatabaseName property to the file biblo.mdb found in your Visual Basic directory.  Set the RecordSource proprety to Authors.

Select the DataTable icon, [image],  from the Toolbox and draw the DataTable on the form.  Resize the DataTable so that it takes up most of the form.  Set the DataSource property to Data1.

Right click on the DataTable and choose Properties... from the floating menu and select the Columns tab page.

Automatically configure the DataTable

Press the Auto Config to DB button.  A message box will appear asking you if you are sure you want to delete the existing columns.  Select Yes.  Press the OK button to dismiss the Properties dialog..

Run the program to see the following output.

Output of Visual Basic Bound example


Visual C++ Example

The following Visual C++ example will demonstrate how to design a DataTable, insert data into the table, and how to write an event procedure.

Create a New Project

Use AppWizard to creata a new project.  Choose New from the File menu item to invoke the New dialog.  Choose Project Workspace from the list and press OK.  The New Project Workspace dialog is now visible.  Choose MFC AppWizard (exe) from the Type list box, enter tutor1 in the Name edit box, and press the Create button.  On the MFC AppWizard - Step 1 dialog choose Dialog Based as the type of application and press the Next button.  On the MFC AppWizard - Step 2 dialog, select the OLE Controls check box and press the Finish button.  This will invoke the New Project Information dialog.  Press the OK button to create the new project.

Add the DataTable to the Dialog

To add the DataTable to the Component Gallery, choose Component from the Insert menu to invoke Component Gallery dialog.  From the OLE Controls tab page, choose the ProtoView DataTable Control icon, and presses the Insert button.  Press the OK button on the Confirm Class dialog.  Press the Close button on the Component Gallery dialog.

From the resource page of the Project Workspace window, choose the dialog IDD_TUTOR1_DIALOG.  Delete the TODO: Place dialog controls here. static text field.  Stretch the new dialog so that it is a bit bigger and move the OK and Cancel buttons so they are still on the right edge of the dialog.

Select the DataTable icon, [image], from the control palette and place the control on the dialog.  Size the DataTable control so that it takes up most of the dialog.

Right click on the DataTable and choose Properties... from the floating menu.  Use the Columns tab page to configure the three columns.

Change the existing columns Type to string, Len to 30, Width to 80, and Heading to Last Name.  When setting the column heading, separate Last and Name with CTRL+ENTER so that the heading takes up two lines.

Press the down arrow to insert another column.  Set the Type to single float, the Width to 70, the Heading to Income, the Format to $#,##0.00 and the Def Val to 30000.

Press the down arrow again to insert the last column.  Set the Type to std checkbox, the Width to 50, and the Heading to Insured.

Configure the DataTable columns

Compile and run the program now to see the following output.

Initial output of Visual C++ Tutor1 example

Our DataTable already has a lot of functionality.  Notice that when the new rows are inserted, the Income column is initialized to the default value. Press the insert key to insert new rows.  Press the delete key to delete the row with the input focus.  Edit the cells by setting the focus on a cell and typing in the new value.  Resize rows and columns by placing the mouse over the grid lines and dragging the grid line.

Adding DataTable Data

Most applications will want to load their own data into the DataTable.  We will now demonstrate how to insert data into the DataTable.

First, add a button to the dialog.  Place the new button under the Cancel button.

Next, use ClassWizard to add a DataTable control pointer.  Invoke ClassWizard by pressing CTRL+W.  Select the Member Variables tab page.  Select IDC_DATATBLCTRL from the Control Ids list box and press the Add Variable  button.  This will invoke the Add member Variable dialog.

Add a member variable for the DataTable

On the Add Member Variable dialog box, enter m_dataTbl in the Member variable name edit box.  Press the OK button to close this dialog.  The Member Variables tab page will reappear now with the member variable listed.

Next, add an event handler for when the new button is clicked.  Switch to the Message Maps tab page.

Use ClassWizard to add the Button1 click event handler

Select IDC_BUTTON1 from the Object Ids list box and BN_CLICKED from the Messages list box.  Press the Add Function button.  This will invoke the Add Member Function dialog.  Press the OK button to add the member function and return to the Message Maps page of the ClassWizard dialog.  Press the Edt Code button to close the ClassWizard dialog and invoke the code editor at the location of the button click event handler.

void CTutor1Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
}

Delete all the current row information.  This is done by calling the DTRowSet objects Reset method.

m_dataTbl.GetRowSet().Reset();

Next, create a variant array to hold the row information.  Since there are three columns, this array should have three items.  Set each item in the variant array to the data desired.  The first element of the array should contain the data for the first column, the second item in the array should contain the data for the second column and so on.

CDTData RowData;
RowData.CreateArray(3);
RowData.PutItem("Smith", 0);
RowData.PutItem(2500.00f, 1);
RowData.PutItem(1L, 2);

Finally, add the new row using the DTRowSet objects Add method.  This method takes two parameters: the location to insert the new row and the new rows data.  Specify that the new row is to be inserted to be inserted at the end of the table by using the constant dtAfterLast.  The new rows data is the variant array that was previously created.

m_dataTbl.GetRowSet().Add(dtAfterLast, RowData);

The entire button click event handler is shown below.

void CTutor1Dlg::OnButton1()
{
// remove all current row information
m_dataTbl.GetRowSet().Reset();

// Create a variant array with an item for each cell value
CDTData RowData;
RowData.CreateArray(3);
RowData.PutItem("Smith", 0);
RowData.PutItem(2500.00f, 1);
RowData.PutItem(1L, 2);

//insert row into DataTable
m_dataTbl.GetRowSet().Add(dtAfterLast, RowData);
}

On the top of the file add the following includes

#include dtocx.h	// include file for DataTable constants
#include dtrowset.h	// include file for the DTRowSet object

Recompile and run the program.  Press on the new button to see the following output.

Output of Visual C++ Tutor1 example after pressing Button1

Add an Event Procedure

Next we are going to use the LfClick event to alternate between hiding and showing the Income column when the user clicks on the top left corner button.

Invoke ClassWizard again by pressing CTRL+W and select the Message Maps tab page.

Use ClassWizard to add the DataTable LfClick event handler

Select IDC_DATATBLCTRL from the Object Ids list box and LfClick from the Messages list box.  Press the Add Function button.  This will invoke the Add Member Function dialog.  Press OK to add the member function and return to the Message Maps page of the ClassWizard dialog.  Press the Edit Code button to close the ClassWizard dialog and invoke the code editor at the location of the LfClick event handler.

void CTutor1Dlg::OnLfClickDatatblctrl1(short Pane, long Row, long Column,
long ClickPos, long FAR* Status)
{
// TODO: Add your control notification handler code here

}

First determine if the click was on the corner button.  The DataTable passes the click positions row and column index to the LfClick event.  If the row is the headings row (defined as dtHeadingsRow) and the column is the labels column (defined as dtLabelsColumn), the click was on the corner button.  We will only continue processing if the click was on the corner button.

if (Row==dtHeadingsRow && Column==dtLabelsColumn)

If the click is on the corner button, we want to toggle whether the Income column is visible.  Since we are affecting a column, we first need to retrieve the DTColumn object for the Income column.  A DTColumn object is retrieved using the DTColumnSet objects Item property.  The Item property takes one parameter; the index of the column to return.  Since the Income column is the second column and columns are indexed starting at zero, specify a value of 1.

CDTColumn Col = m_dataTbl.GetColumnSet().GetItem(1);

Once we have the Income columns DTColumn object, we can access the Hidden property.  Toggle the Hidden property by setting the Hidden property to the logical not of the current value of the Hidden property.

Col.SetHidden(!Col.GetHidden());

The entire LfClick event procedure is shown below.

void CTutor1Dlg::OnLfClickDatatblctrl1(short Pane, long Row, long Column,
long ClickPos, long FAR* Status)
{
// if click was on the corner button
if (Row==dtHeadingsRow && Column==dtLabelsColumn)
{
// retrieve the DTColumn object for the Income column
CDTColumn Col = m_dataTbl.GetColumnSet().GetItem(1);
// toggle the hidden flag
Col.SetHidden(!Col.GetHidden());
}
}

At the top of the file, add two more headers for the ColumnSet and DTColumn objects.

#include "dtcolumnset.h"	// DTColumnSet object header
#include "dtcolumn.h"	// DTColumn object header

Recompile and run the program now.  The program output will appear the same, but by clicking on the corner button, the Income column will disappear and reappear.


Delphi Example

The following Delphi example will demonstrate how to design a DataTable, insert data into the table, and how to write an event handler.

Create a New Project

If the DataTable OCX has not been installed see Installing the DataTable in Delphi.

Start a new project by choosing the New from the File menu.  This will invoke the New Items dialog.  Select the Application icon on the New tab page and press OK.

Painting the DataTable

Select the DataTable icon, [image], from the Component palette and draw the DataTable on the form.  Size the DataTable so that it takes up most of the form..

Right click on the DataTable and choose Properties... from the floating menu.  Use the Columns tab page to configure the three columns.

Change the existing columns Type to string, Len to 30, Width to 80, and Heading to Last Name.  When setting the column heading, separate Last and Name with  CTRL+ENTER so that the heading takes up two lines.

Press the down arrow to insert another column.  Set the Type to single float, the Width to 70, the Heading to Income, the Format to $#,##0.00 and the Def Val to 30000.

Press the down arrow again to insert the last column.  Set the Type to std checkbox, the Width to 50, and the Heading to Insured.

Configuring columns in Delphi

Press the OK button when you are done configuring the last column.

Run the program now to see the following output.

Initial output of Delphi Tutor1 example

Our DataTable already has a lot of functionality.  Notice that when new rows are inserted, the Income column is initialized to the default value.  Press the insert key to insert new rows.  Press the delete key to delete the row with the input focus.  Edit the cells by setting the focus on a cell and typing in the new value.  Resize rows and columns by placing the mouse over the grid lines, pressing the left mouse button, and dragging the grid line to the new size..

Adding DataTable Data

Most applications will want to load their own data into the DataTable.  We will now demonstrate how to insert data into the DataTable.

Add a button to the form.  Double click on the button to add an event procedure to the Click event.

First delete all the current row information.  This is done by calling the DTRowSet objects Reset method.

DatatblCtrl1.RowSet.Reset;

Next create a variant array to hold the row information.  Since there are three columns, this array should have three items.  Set each item in the variant array to the data desired.  The first element of the array should contain the data for the first column, the second item in the array contains the data for the second column, and so on.

var
   RowData : Variant;

     {Create Variant array with an item for each cell }
     RowData := VarArrayOf(['Smith', 25000, 1]);

Finally, add the new row using the DTRowSet objects Add method.  This method takes two parameters: the location to insert the new row and the new rows data.  Specify that the new row is to be inserted to be inserted at the end of the table by using the constant dtAfterLast.  The new rows data is the variant array that was previously created.

procedure TForm1.Button1Click(Sender: TObject);
var
   RowData : Variant;
begin
     {Remove all Row information}
     DatatblCtrl1.RowSet.Reset;

     {Create Variant array with an item for each cell }
     RowData := VarArrayOf(['Smith', 25000, 1]);

     {Add the row to the end of the table }
     DatatblCtrl1.RowSet.Add (dtAfterLast, RowData);
end;

The entire Click event handler is shown below.

procedure TForm1.Button1Click(Sender: TObject);
var
   RowData : Variant;
begin
     {Remove all Row information}
     DatatblCtrl1.RowSet.Reset;

     {Create Variant array with an item for each cell }
     RowData := VarArrayOf(['Smith', 25000, 1]);

     {Add the row to the end of the table }
     DatatblCtrl1.RowSet.Add (dtAfterLast, RowData);
end;

Run the program and press on the new button to see the following output.

Output of Delphi Tutor1 example after pressing Button1

Add an Event Procedure

Next we are going to use the LfClick event to alternate between hiding and showing the Income column when the user clicks on the top left corner button.

From the Object Inspector Window, select DatatblCtrl1 from the object list and switch to the Events tab page.  Double click on the OnLfClick event to create an event handler and place the cursor at this new handler.

procedure TForm1.DatatblCtrl1LfClick(Sender: TObject; Pane: Integer; Row,
  Column, ClickPos: Integer; var Status: Integer);
 begin
end;

First determine if the click was on the corner button.  The DataTable passes the click positions row and column index to the LfClick event.  If the row is the headings row (defined as dtHeadingsRow) and the column is the labels column (defined as dtLabelsColumn), the click was on the corner button.  We will only continue processing if the click was on the corner button.

if (Row = dtHeadingsRow) and (column = dtLabelsColumn) then
     begin
     end;

If the click is on the corner button, we want to toggle whether the Income column is visible.  Since we are affecting a column, we first need to retrieve the DTColumn object for the Income column.  A DTColumn object is retrieved using the DTColumnSet objects Item property.  The Item property takes one parameter; the index of the column to return.  Since the Income column is the second column and columns are indexed starting at zero, specify a value of 1.

DataTblCtrl1.ColumnSet.Item(1)

Once we have the Income columns DTColumn object, we can access the Hidden property.

DataTblCtrl1.ColumnSet.Item(1).Hidden

First retrieve the current value of the Hidden property and then set the Hidden property to the logical not of the retrieved value.

var
   bHidden : boolean;

bHidden := DataTblCtrl1.ColumnSet.Item(1).Hidden;
DataTblCtrl1.ColumnSet.Item(1).Hidden := not bHidden;

The entire LfClick event procedure is shown below.

procedure TForm1.DatatblCtrl1LfClick(Sender: TObject; Pane: Integer; Row,
  Column, ClickPos: Integer; var Status: Integer);
var
   bHidden : boolean;
begin
     {Determine if the click was on the corner button}
     if (Row = dtHeadingsRow) and (column = dtLabelsColumn) then
     begin
          {determine if the income column is currently hidden }
          bHidden := DataTblCtrl1.ColumnSet.Item(1).Hidden;
          DataTblCtrl1.ColumnSet.Item(1).Hidden := not bHidden;
     end;
end;

Run the program now.  The program output will appear the same but by clicking on the corner button, the Income column will disappear and reappear.


The DataTable Object


DataTable Object Overview

The DataTable object contains methods and properties which affect the entire table.  For example, the DataTable objects Font property specifies the font used for the entire DataTable.

The DataTable is also the door to accessing the other DataTable objects.  The DataTable properties which return objects are: RowSet which returns a DTRowSet object, ColumnSet which returns a DTColumnSet object, CellSet which returns a DTCellSet object, and CurCell which returns a DTCurCell object.


The DataTable Appearance

The following section describes DataTable colors, font, grid lines, scroll bars, and the drop down feature.

DataTable Colors

The DataTable background color, text color, background color of selected items, and text color of selected items used when paint the DataTable can be specified.

At design time, use the Colors tab page to set the colors used when painting the DataTable.  At run time use the DataTable objects BackColor, ForeColor, SelBackColor, and SelForeColor properties.

Since colors can be assigned to the DataTable, the current cell, a row, a column and a cell, the DataTable uses an order of priority to decide which color group to use when painting a particular cell.  The order of priority, from high to low, is: current cell colors, cell colors, row colors,  column colors, and DataTable colors.

Visual Basic Example

Datatbl1.BackColor = RGB(192, 192, 192)

Visual C++ Example

m_DataTbl.SetBackColor (RGB(192, 192,192));

Color Priority

A cell can have overlapping color assignments.  For example, a particular cell can have a background color assigned to the cells row and a background color assigned to the cells column.  To resolve this problem, the DataTable uses the following list to decide which color assignment to use.

1.   Is this the current cell and has this current cell color been assigned?  Use the current cell color.

2.   Has this color been assigned to this cell?  Use the cell color.

3.   Has this color has been assigned to this row?  Use the row color.

4.   Has this color has been assigned to this column?  Use the column color.

5.    Use the DataTable color.

According to these rules, setting a DataTable color will not override the column, row, cell, or the current cell color.

DataTable Font

The font used when drawing DataTable text can be specified at design time using the Fonts tab page.  At run time use the DataTable objects Font property.

Use the font objects Bold, Italic, Name, Size, StrikeThrough, Underline, and Weight properties to alter the DataTable font.  The following example sets the DataTable font objects Bold property to TRUE.

Visual Basic Example

DataTbl1.Font.Bold = True

Visual C++ Example

m_dataTbl.GetFont().SetBold (TRUE);

Font Priority

A cell can have overlapping font assignments.  For example, a particular cell can have a font assigned to the cells row and a font assigned to the cells column.  To resolve this problem, the DataTable uses the following list to decide which font assignment to use.

1.   Is this the current cell and has a current cell font been assigned?  Use the current cell font.

2.   Has a font been assigned to this cell?  Use the cell font.

3.   Has a font has been assigned to this row?  Use the row font.

4.   Has a font has been assigned to this column?  Use the column font.

5.   Use the DataTable font.

According to the above rules, the DataTable font will not override the column, row, cell, or the current cell font.

Grid Lines

The DataTable can display horizontal and vertical grid lines to separate rows and columns.

At design time, use the Horz Grid Lines and Vert Grid Lines check boxes found on the General tab page to enable or disable horizontal and vertical gridlines.  At run time, use the DataTable objects HorzGridLines  and VertGridLines properties.

The color of the grid lines can also be specified.  At design time, use the Colors tab page to set the color of the gridlines.  At run time, use the DataTable objects GridLineColor property.

Visual Basic Example

Datatbl1.HorzGridLines = True
Datatbl1.GridLineColor = RGB(255,0,0)

Visual C++ Example

m_DataTbl.SetHorzGridLines (TRUE);
m_DataTbl.SetGridLineColor (RGB(255,0,0));

Scroll Bars

The DataTable can display horizontal and vertical scroll bars.

At design time, use the Horz Scroll Bar and Vert Scroll Bar combo boxes found on the General tab page to specify when the horizontal and vertical scroll bars will appear.  At run time, use the DataTable objects HorzScrollBar  and VertScrollBar properties.

The scroll bars can be set to never appear, appear only when needed, or always appear.

If the scroll bars are set to appear only when needed, the DataTable displays a horizontal scroll bar only when the width of all of the columns is greater then the DataTable window width and a vertical scroll bar only when the height of  all of the DataTable rows is greater then the DataTable window height.

Using DataTable Auto Drop Down and Drop Down Styles

A DataTable configured with either the Drop Down or the Auto-Drop Down style allows the table to be displayed in two states: dropped down or closed up.  A closed up DataTable has only the column headings and first row visible.  When the user wishes to see the whole DataTable it can be dropped down.  Drop down tables are useful when screen space is limited.

The table is dropped down or closed up by using the ALT+DOWN arrow and ALT+UP arrow keys.  An Auto-Drop Down table which has the additional capability of automatically drops down when it receives the focus, and closes up when it looses the focus.

At design time, use the Drop Down combo box found on the General tab page to set the drop down type.  At run time, use the DataTable objects DropDown property.

Visual Basic Example

DataTbl1.DropDownType = ddAutoDropDown

Visual C++ Example

m_dataTbl.SetDropDownType(ddAutoDropDown);


Reset All DataTable Information

A DataTable can be completely cleared of all information by calling the DataTable Reset method.  This method removes all row and column information.

Visual Basic Example

Datatbl1.Reset

Visual C++ Example

m_DataTbl.Reset();


Window Splitting

The DataTable window can be split horizontally and vertically.

A table which is split horizontally displays unlocked columns in both a left and right pane.  The right and left pane scroll horizontally independent and vertically together.

A table which is split vertically displays rows in both the top and bottom pane.  The top and bottom pane scroll horizontally together and vertically independent.

Window splitting is enabled at design time using the Split Window Horz and Split Window Vert check boxes found on the General tab page.  At run time, use the DataTable objects HorzSplitPane and VertSplitPane properties.

Visual Basic Example

Datatbl1.HorzSplitPane = True

Visual C++ Example

m_DataTbl.SetHorzSplitPane (TRUE);

Setting the Pane Size

To set the width of the left pane at design time, use the LF Pane Width edit box found on the General tab page.  At run time, use the DataTable objects LeftPaneWidth property.  Set this property to the constant dtMaxPaneSize (defined as -1) to set the width to the maximum width.  The maximum width is the client area width minus the width of the row labels and the locked columns.  The left pane width is expressed in the scale units of the DataTable's container.

To set the height of the top pane at design time, use the Top Pane Height edit box found on the General tab page. At run time, use the DataTable objects TopPaneHeight property.  Set this property to the constant dtMaxPaneSize (defined as -1) to set the height to the maximum height.  The maximum height is the client area height minus the height of the column headings.  The height is expressed in the scale units of the DataTable's container.

Visual Basic Example

Datatbl1.HorzSplitPane = True

Visual C++ Example

m_DataTbl.SetHorzSplitPane (TRUE);

The user can resize the panes by pressing the left mouse button on the horizontal or vertical splitter bar and, while holding the mouse button, drag the splitter bar to a new location.

Working with Split Panes

The DataTable methods, properties, and events frequently need to specify which pane is affected.

The DataTable uses the following constants to identify the different panes:

Constant	Meaning
paneLabelTop	Row label column, Top Pane
paneLockedTop	Locked column pane, Top Pane
paneLeftTop	Left Pane, Top Pane
paneRightTop	Right Pane, Top Pane
paneLabelBottom	Row label column, Bottom Pane
paneLockedBottom	Locked column pane, Bottom Pane
paneLeftBottom	Left Pane, Bottom Pane
paneRightBottom	Right Pane, Bottom Pane
paneLeft	Left Pane
paneRight	Right Pane
paneTop	Top Pane
paneBottom	Bottom Pane
Affected Properties, Methods and Events

Since there is both a left and right pane, the DTColumnSet objects FirstVisible property and GetVisCount method needs to know if the programmer wishes to affect the left or the right pane.

Likewise, since there is both a top and bottom pane. the DTRowSet objects FirstVisible property and  GetVisCount method needs to know if the programmer wishes to affect the top or bottom  pane.

The DTCellSet objects GetCellAtPoint method will return not only the column and row index of the cell located at the specified point, but also the pane number.

Since a cell can be visible in more then one pane, the DTCell object GetRect method needs to know which pane to retrieve the cell rectangle for.

The LfClick, RtClick, LfDblClick, and RtDblClick events all report the pane where the click occurred.  The PaintCell event reports which pane the cell is being painted in.


Owner Drawn Cells

The DataTable has an owner draw feature that lets the parent (or owner) window draw whatever it wants in a DataTable cell.

Owner drawn cells are implemented by: trapping the PaintCell event, determining if this is a cell the parent wishes to be paint, retrieving the bounding cell rectangle, painting the cell, and finally informing the DataTable not to paint the cell.

In order to trap the PaintCell event, the PaintCell event must be enabled.  The PaintCell event is enabled by checking the Paint Cell Event on the General tab page at design time or by setting the DataTable objects AllowPaintCellEvent property to TRUE at run time.

The parent can determine if this is a cell it wishes to paint by looking at the PaintCell event parameters.  The PaintCell event passes the pane, row and column index of the cell to be painted.  If the cell being painted is in the column headings row, the row index will be the constant dtHeadingsRow.  If the cell being painted is in the row labels column, the column index will be the constant dtLabelsColumn.

The bounding rectangle of a cell is determined using the DTCell objects GetRect method.  This method returns TRUE if the cell is currently visible and stores the rectangle coordinates in the passed parameters: Left, Top, Right, and Bottom. The coordinates are returned in the scale units of the DataTable's container.

The parent is free to paint whatever it wants in the cells bounding rectangle.  Visual Basic programmers must include the DataTable in the clipping region in order to paint in the DataTable area .  This is done by setting the DataTables parent ClipControl property to FALSE.  See chapter 15, Creating Graphics for Applications, of your Visual Basic Programmers Guide manual for more information.

The DataTable must be informed not to paint the cell.  This is done by setting the PaintCell events Status parameter to a non-zero value.

Visual Basic Example

Private Sub Datatbl1_PaintCell(ByVal Pane As Integer, ByVal Row As Long,
ByVal Column As Long, Status As Long)

    ' variables to hold the cells bounding  rectangle
    Dim left As Single, top As Single, right As Single, bottom As Single
    Dim width As Integer, height As Integer

    ' paint the cell located at the first row, first column
    If (Column = 0 And Row = 0) Then
        ' get the cell bounding rectangle
        Datatbl1.CellSet(Row, Column).GetRect Pane, left, top, right, bottom
        width = (right - left)
        height = (bottom - top)
        left = left + Datatbl1.left
        top = top + Datatbl1.top
        ' Paint the cell Red
        Line (left, top)-Step(width, height), RGB(255, 0,0), BF
         Tell the DataTable not to paint the cell
        Status = 1
    End If
End Sub

Visual C++ Example

void CTestDlg::OnPaintCellDatatblctrl1(short Pane, long Row, long Column,
long FAR* Status)
{
// paint the cell located at the first row, first column
if (Row==0 && Column==0)
{
// variables to hold the cells bounding  rectangle
float left, top, right, bottom;

// get the cell bounding rectangle
CDTCell cell = m_dt.GetCellSet().GetItem(Row, Column);
cell.GetRect (Pane, &left, &top, &right, &bottom);
CRect Rect = CRect((int) left, (int) top, (int) right, (int) bottom);

// Paint the cell RED
CDC * pdc = m_dt.GetDC();
CBrush * brush = new CBrush (RGB(255,0,0));
pdc->FillRect(Rect, brush);
m_dt.ReleaseDC(pdc);

 Tell the DataTable not to paint the cell
*Status = 1L;
}
}


Virtual Memory

In a virtual memory table, the DataTable retains only the row data needed to display the current visible page. Additional data is requested from the parent when needed.  The parent window is responsible for maintaining all row data.

There are several advantages to using a virtual memory management scheme.  A virtual memory table reduces the overhead required.  The parent window does not need to insert all rows at initialization; only one page.  The number of rows can be unknown and the rows can even be identified by a user defined value.

There are two disadvantages to a virtual memory managed table: scrolling speed is slower and the additional code must be written to respond to the DataTable queries.

Enabling Virtual Memory

Virtual memory is enabled at design time with the Virtual Memory combo box found on the General tab page.  At run time, set the DataTable objects VirtualMemType property to either vmIndexed or vmUserDefined.

Use vmIndexed when sequential row numbers can be used to identify the row.

If the table uses an user defined key to identify the rows, set DataTable objects VirtualMemType to vmUserDefined.  The user defined key must fit in 4 bytes.  Whenever possible, the user should use indexed row keys.

Initiating Communications

The DataTables parent window must initiate communications to inform the DataTable that is ready to process the DataTables request for row information.

The parent window initiates communication by calling the DataTable VMReady method.  This method expects one parameter, the number of rows.  If the number of rows is not known, the parent should pass a zero to the VMReady method.

When the number of items is unknown, the DataTable places the scroll bar shuttle in the middle of the scroll bar.  This allows the user to scroll up one line, down one line, page up, and page down.  The user can also move the scroll bar shuttle to a position representing a percentage down the table.  The scroll bar shuttle always returns to the middle of the scroll bar.  This can be confusing to the user, therefore whenever possible, the parent should determine the number of rows.

Visual Basic Example

DataTbl.VMReady 1000	' number of rows is 1000,  ready for events

Visual C++ Example

m_dataTbl.VMReady (1000);	// number of rows is 1000, ready to receive events

Requesting Information

The DataTable requests information from the parent by firing a virtual memory event when it needs a row of data.  The following table describes the different virtual memory events.

Type	Description
VMGetFirst	Get the first row of data.
VMGetLast	Get the last row of data.
VMGetNext	Get the row of data after the row specified by VMDataKey.
VMGetPrev	Get the row of data prior to the row specified by VMDataKey.
VMGetPercent	Get the row of data that is the percent specified by VMDataKey down the table.
VMGetRowData	Get the row of data specified by VMDataKey.

The parent should process the virtual memory events by:

1.   Setting the VMDataKey property to the data key of the requested row.  This step must be done first.

2.   Retrieving either a DTRow or DTCell object specifying the new value for VMDataKey as the row index and set the objects Value property to the requested rows data.

Each event passes a parameter called Status.  If the requested information can not be returned, the parent should set the Status parameter to non-zero.

Initially, the DataTable will fire the VMGetFirst event to fetch the first row of data.  The parent responds by setting the VMDataKey property to the data key of the first row, retrieving a DTRow or DTCell object specifying VMDataKey as the row index, and setting the Value property.

The VMGetFirst event will be followed by multiple VMGetNext events until the first visible page is full.  The parent must respond to each VMGetNext event by setting VMDataKey to the data key of the next row and setting the rows data.

As the user scrolls the DataTable, using the keyboard or scroll bars, the DataTable will send virtual memory events to the parent to retrieve more data.  For example, if the user presses page down, the DataTable will fire a VMGetNext event specifying the current page's last row's data key in VMDataKey property.  This event will be followed by other VMGetNext until the new page is full.  Each VMGetNext will specify the key of the row last fetched.

Visual Basic Example

Private Sub DataTbl1_VMGetFirst(Status As Long)
    DataTbl1.VMDataKey = 0
    DataTbl1.CellSet(DataTbl1.VMDataKey, 0).Value = "Row " +
Str(DataTbl1.VMDataKey)
    DataTbl1.CellSet(DataTbl1.VMDataKey, 1).Value = DataTbl1.VMDataKey
End Sub

Private Sub DataTbl1_VMGetLast(Status As Long)
    DataTbl1.VMDataKey = Last
    DataTbl1.CellSet(DataTbl1.VMDataKey, 0).Value = "Row " +
Str(DataTbl1.VMDataKey)
    DataTbl1.CellSet(DataTbl1.VMDataKey, 1).Value = DataTbl1.VMDataKey
End Sub

Private Sub DataTbl1_VMGetNext(Status As Long)
    If DataTbl1.VMDataKey < Last Then
        DataTbl1.VMDataKey = DataTbl1.VMDataKey + 1
        DataTbl1.CellSet(DataTbl1.VMDataKey, 0).Value = "Row " +
Str(DataTbl1.VMDataKey)
        DataTbl1.CellSet(DataTbl1.VMDataKey, 1).Value = DataTbl1.VMDataKey
    Else
        Status = 1
    End If
End Sub

Private Sub DataTbl1_VMGetPercent(Status As Long)
    DataTbl1.VMDataKey = DataTbl1.VMDataKey * (Last / 100)
    DataTbl1.CellSet(DataTbl1.VMDataKey, 0).Value = "Row " +
Str(DataTbl1.VMDataKey)
    DataTbl1.CellSet(DataTbl1.VMDataKey, 1).Value = DataTbl1.VMDataKey
End Sub

Private Sub DataTbl1_VMGetPrev(Status As Long)
    If DataTbl1.VMDataKey > 0 Then
        DataTbl1.VMDataKey = DataTbl1.VMDataKey - 1
        DataTbl1.CellSet(DataTbl1.VMDataKey, 0).Value = "Row " +
Str(DataTbl1.VMDataKey)
        DataTbl1.CellSet(DataTbl1.VMDataKey, 1).Value = DataTbl1.VMDataKey
    Else
        Status = 1
    End If

Visual C++ Example

// the following function just creates data for the first cell
void GetCell0Data(CDTData *Var, long Row)
{
char buffer[20];
sprintf(buffer, "RowInfo %ld", Row);
*Var = buffer;
}
// the following function just creates data for the second cell
void GetCell1Data(CDTData *Var, long Row)
{
*Var = Row;
}

void CVmDlg::OnVMGetFirstDatatblctrl1(long FAR* Status)
{
long Row = 0;
m_dt.SetVMDataKey (Row);	// always set before setting data
CDTData Var;
GetCell0Data(&Var, Row);
m_dt.GetCellSet().GetItem(Row, 0).SetValue(Var);
GetCell1Data(&Var, Row);
m_dt.GetCellSet().GetItem(Row, 1).SetValue(Var);
}

void CVmDlg::OnVMGetLastDatatblctrl1(long FAR* Status)
{
long Row= NUMROWS;
m_dt.SetVMDataKey (Row);	// always set before setting data
CDTData Var;
GetCell0Data(&Var, Row);
m_dt.GetCellSet().GetItem(Row, 0).SetValue(Var);
GetCell1Data(&Var, Row);
m_dt.GetCellSet().GetItem(Row, 1).SetValue(Var);
}

void CVmDlg::OnVMGetNextDatatblctrl1(long FAR* Status)
{
long Row = m_dt.GetVMDataKey();
if (Row >= NUMROWS-1)
*Status=1;
else
{
Row++;
m_dt.SetVMDataKey (Row);	// always set before setting data
CDTData Var;
GetCell0Data(&Var, Row);
m_dt.GetCellSet().GetItem(Row, 0).SetValue(Var);
GetCell1Data(&Var, Row);
m_dt.GetCellSet().GetItem(Row, 1).SetValue(Var);
}
}

void CVmDlg::OnVMGetPercentDatatblctrl1(long FAR* Status)
{
long Row = m_dt.GetVMDataKey();
// always set before setting data
m_dt.SetVMDataKey (Row*(NUMROWS/100));
CDTData Var;
GetCell0Data(&Var, Row);
m_dt.GetCellSet().GetItem(Row, 0).SetValue(Var);
GetCell1Data(&Var, Row);
m_dt.GetCellSet().GetItem(Row, 1).SetValue(Var);
}

void CVmDlg::OnVMGetPrevDatatblctrl1(long FAR* Status)
{
long Row = m_dt.GetVMDataKey();
if (Row <= 0)
*Status=1;
else
{
Row--;
m_dt.SetVMDataKey (Row);	// always set before setting data
CDTData Var;
GetCell0Data(&Var, Row);
m_dt.GetCellSet().GetItem(Row, 0).SetValue(Var);
GetCell1Data(&Var, Row);
m_dt.GetCellSet().GetItem(Row, 1).SetValue(Var);
}
}

void CVmDlg::OnVMGetRowDataDatatblctrl1(long FAR* Status)
{
long Row = m_dt.GetVMDataKey();
if (Row< 0 || Row> NUMROWS-1)
*Status=1;
else
{
// VMDataKey does not need to be set
CDTData Var;
GetCell0Data(&Var, Row);
m_dt.GetCellSet().GetItem(Row, 0).SetValue(Var);
GetCell1Data(&Var, Row);
m_dt.GetCellSet().GetItem(Row, 1).SetValue(Var);
}
}

Virtual Memory Limits

If the DataTable allows the user to edit cells, it is the parent's responsibility to update its copy of the row data when a cell has been edited.  The parent is notified of changes to a visible cell via the UpdateCell event.

To update the displayed page, use the DTRowSet objects FirstVisible property .  Avoid inserting and deleting rows by updating the displayed page.  To reinitialize the data, reset the VMReady property.

A virtual memory table does not allow vertical window splitting or multiple row selection. Column manipulation (inserting, deleting, moving, searching, and sorting) is not allowed on a virtual memory DataTable after data is initialized.


Column Objects


Column Objects Overview

The DataTable uses the DTColumnSet and DTColumn objects to encapsulate properties and methods which affect the appearance and behavior of the DataTable columns.

The DTColumnSet object encapsulates methods and properties which affect all DataTable columns.  For example, the DTColumnSet objects AllowResize property represents whether all columns can be resized.   The DTColumnSet object is retrieved using the DataTable objects ColumnSet property.

Visual Basic Example

Dim ColumnSetObj As DTColumnSet
Set ColumnSetObj = DataTbl1.ColumnSet

Visual C++ Example

CDTColumnSet ColumnSetObj = m_dataTbl.GetColumnSet()

The DTColumn object encapsulates methods and properties which affect a particular column.  For example, the DTColumn objects Resize property represents whether a particular column can be resized.  A DTColumn object is retrieved using the DTColumnSet objects Item property and specifying the index of the column to retrieve. (Columns are indexed starting at zero.) The Item property is the default property, therefore Visual Basic programmers need not specify the property name.

Visual Basic Example

Dim ColumnObj As DTColumn
 the following two lines are equivalent
Set ColumnObj = DataTbl1.ColumnSet.Item(ColIndex).Item
Set ColumnObj = DataTbl1.ColumnSet (ColIndex)

Visual C++ Example

CDTColumn ColumnObj;
ColumnObj = m_dataTbl.GetColumnSet().GetItem (ColIndex);


Manipulating DataTable Columns

DataTable columns can be added, removed, copied, and moved using the DTColumnSet Add, Remove, Copy, and Move methods.

Adding DataTable Columns

A column is added to the DataTable using the DTColumnSet objects Add method.

The Add method takes one parameter, the destination.  The destination is specified by the index of the column the new column is to be inserted prior to.  A column is added after the last column by specifying the constant dtAfterLast as the destination.

The following example adds a column before the second column.

Visual Basic Example

Datatbl1.ColumnSet.Add 1

Visual C++ Example

m_DataTbl.GetColumnSet().Add (1);

Newly inserted columns will be initially empty of any data.  To add data to the new column use the DTColumn objects Value property.

The DataTable informs its parent when a column has been added by firing the ColAdded event.  This event row one parameter, the index of the new column.

Removing a Column

A column is removed from the DataTable using the DTColumnSet objects Remove method.

The Remove method takes one parameter, the index of the column to remove.  (Columns are indexed starting at zero.)   The following example removes the third column.

Visual Basic Example

Datatbl1.ColumnSet.Remove(2)

Visual C++ Example

m_DataTbl.GetColumnSet().Remove(2);

The DataTable informs its parent when a column has been removed by firing the ColDeleted event.  This parameter row one parameter, the index of the deleted column.

Coping Columns

A column is copied in the DataTable using the DTColumnSet objects Copy method.

The Copy method takes two parameters: the source and the destination.  The source is the index of the column to copy.  The destination is the index of the column the source column is copied prior to.  A column is copied after the last column by specifying the constant dtAfterLast as the destination.

The following example copies the third column after the last column.

Visual Basic Example

Datatbl1.ColumnSet.Copy(2, dtAfterLast)

Visual C++ Example

m_DataTbl.GetColumnSet().Copy(2, dtAfterLast);

Moving Columns

A column is moved in the DataTable using the DTColumnSet objects Move method.

This method takes two parameters: the source and the destination.  The source is the index of the column to move.  The destination is the index of the column the source column is moved prior to.  A column is moved after the last column by specifying the constant dtAfterLast as the destination.

The following example moves the third column after the last column.

Visual Basic Example

Datatbl1.ColumnSet.Move(2, dtAfterLast)

Visual C++ Example

m_DataTbl.GetColumnSet().Move(2, dtAfterLast);

The DataTable informs its parent when a column has been moved by firing the ColMoved event.  This event row one parameter, the index of the moved column.


Column Appearance

The following section describes column colors, fonts, display width, locking, headings, drop down lists, and formatting.

Column Display Width

The column display width can be specified at design time using the Width field found on the Columns tab page.  At run time, use the DTColumn objects Width property to set and return the display width for a column.

The display width is expressed in the scale units of the DataTable's container.

The DataTable informs its parent when a column has been resized by firing the ColSize event.  This event passes one parameter, the index of the resized column.

Column Colors

The DTColumn objects BackColor, ForeColor, SelBackColor, and SelForeColor properties are used to set and return the colors used when painting a particular column.

BackColor represents the column background color, ForeColor represents the column text color, SelBackColor represents the column background color for selected items, and SelForeColor represents the column text color for selected items.

The following example sets the background color and selected background color of the first column to gray.

Visual Basic Example

DataTbl1.ColumnSet(0).BackColor = RGB(192, 192, 192)
DataTbl1.ColumnSet(0).SelBackColor = RGB(192, 192, 192)

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetBackColor(RGB(192,192,192));
m_dataTbl.GetColumnSet().GetItem(0).SetSelBackColor(
RGB(192,192,192));

Color Priority

A cell can have overlapping color assignments.  For example, a particular cell can have a background color assigned to the cells row and a background color assigned to the cells column.  To resolve this problem, the DataTable uses the following list to decide which color assignment to use.

1.   Is this the current cell and has this current cell color been assigned?  Use the current cell color.

2.   Has this color been assigned to this cell?  Use the cell color.

3.   Has this color has been assigned to this row?  Use the row color.

4.   Has this color has been assigned to this column?  Use the column color.

5.   Use the DataTable color.

According to these rules, setting a column color will override the DataTable color, but will not override the row, cell, or the current cell color.

Column Font

The font used when drawing a particular columns text is represented by the DTColumn objects Font property.

Initially a font is not assigned to the column. Before any of the font properties can be accessed, a font object must be assigned

To assign a column font, Visual Basic customers need to create a font object by declaring a new StdFont object and then set the column Font property to the new object.

Dim X As New StdFont
 Set the font attributes
X.Name = MS Sans Serif
X.Bold = TRUE
X.Size = 12
Set Datatbl1.ColumnSet(0).Font = X

Visual C++ customers need to create a font dispatch pointer, create a COleFont property using the font dispatch pointer, and then set the Font  property to the new COleFont object.  The Microsoft function OleCreateFontIndirect can be used to create a font dispatch pointer.

LPDISPATCH pFontDisp = NULL;
// Set the font attributes
FONTDESC fontDesc = { sizeof(FONTDESC), OLESTR("MS Sans Serif"),
FONTSIZE(12), FW_NORMAL, DEFAULT_CHARSET, FALSE, FALSE,
FALSE };

// Create the font dispatch pointer
OleCreateFontIndirect((LPFONTDESC)&fontDesc, IID_IFont,
(LPVOID *)&pFontDisp);

// Create the Ole Font
COleFont *NewFont = new COleFont(pFontDisp);
m_dataTbl.GetColumnSet().GetItem(0).SetFont(*NewFont);

Once a font has been assigned to a column, use the font Bold, Italic, Name, Size, StrikeThrough, Underline, and Weight properties to alter the column font.  The following example sets the first columns font objects Bold property to TRUE.

Visual Basic Example

DataTbl1.ColumnSet(0).Font.Bold = True

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).GetFont.SetBold (TRUE);

To remove a previously assigned column font, Visual Basic programmers set the Font property to Nothing

DataTbl1.ColumnSet(0).Font = Nothing

and Visual C++ programmers set the Font property to NULL.

m_dataTbl.GetColumnSet().GetItem(0).SetFont(NULL);

To determine if a font has been assigned to a column, Visual Basic programmers check if the Font property is Nothing

If (Datatbl1.ColumnSet(0).Font Is Nothing) Then

and Visual C++ programmers check if the Font property is NULL.

if (m_dataTbl.GetColumnSet().GetItem(0).GetFont() == NULL)

Font Priority

A cell can have overlapping font assignments.  For example, a particular cell can have a font assigned to the cells row and a font assigned to the cells column.  To resolve this problem, the DataTable uses the following list to decide which font assignment to use.

1.   Is this the current cell and has a current cell font been assigned?  Use the current cell font.

2.   Has a font been assigned to this cell?  Use the cell font.

3.   Has a font has been assigned to this row?  Use the row font.

4.   Has a font has been assigned to this column?  Use the column font.

5.   Use the DataTable font.

According to the above rules, setting the column font will override the DataTable font, but will not override the row, cell, or the current cell font.

Column Headings

If custom headings are specified, the column heading text can be specified for each column.  (Column headings are enabled using the DTRowSet objects HeadingType property.)

At design time, use the Heading field on the Columns tab page to specify the column heading text.  At run time, use the DTColumn objects Heading property.

Column Locking

The DataTable allows columns to be locked on the active window.  Locked columns are displayed on the far left of the window.  Locked columns do not scroll horizontally, but do scroll vertically.  Locked columns are useful when column data must remain visible.

A column is locked or unlocked at design time using the Locked field found on the Columns tab page.  At run time use the DTColumn objects Locked property.

Locked columns are displayed on the left of the window in numeric order.  Unlocked columns are displayed in numeric order to the right of the locked columns.  For example, if there are eight columns and columns 2, 6 and 7 are locked, the column display order is 2, 6, 7, 1, 2, 3, 4, 5, 8.  The locked and unlocked columns are separated by a double horizontal grid line.

The following example locks the third column.

Visual Basic Example

DataTbl1.ColumnSet(2).Locked = True

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(2).SetLocked( TRUE );

Columns with Drop Down Lists

Any column, except a column of type dttCheckbox or dttBitmap, can be display a drop down list box while editing.

A column displays a drop down list box if a list of items is assigned to it.  At design time, a list of items can be assigned to a column using the List field on the Columns tab page.  At run time, use the DTColumn object List property.  List items are separated by the Tab character.

If the column is editable and a list has been assigned, the column behaves as a combo box.  If the column is not editable and a list has been assigned, the column behaves as a drop down list box.

Column Formatting

Each column may have its data formatted according to a format string.

At design time, the formatting string is set using the Format field found on the Columns tab page.  At run time, use the DTColumn objects Format property.

The formatting string can contain formatting codes, a fill code, and literal text.  The formatting codes are separated into 5 types: string codes, numeric codes, date codes, time codes and Boolean codes.  Each type, as well as the fill code and literal text is described below.

Literal Text

The format string can contain literal text.  Literal text is displayed without interpretation.  Literal text includes: any character which cannot be interpreted as a formatting code, any character preceded by a backslash, and any string of characters surrounded by quotes.  The following table contains examples of literals.

Literal	Displays
\c	c  (the character 'c', whatever it is)
\\	\   (a backslash)
\"	"   (a quote)
"abc"	abc
"\"hello\""	"hello"
Fill Codes

Normally, any space in a cell not occupied by the data being displayed is filled with spaces.  A different character may be specified by following the fill code, which is symbolized by an asterisk, with the desired fill character.  The fill characters are inserted into the displayed data at the position indicated by the fill codes position within the format string.  The following table contains examples of format strings with fill codes.  (Vertical bars are used to indicate the cell boundaries).

Format String	Cell Value	Displays
@*-	Smith	|Smith----------|
*-@	Smith	|----------Smith|
**0.00	123.45	|*********123.45|
String Codes

String codes cause the cell's data to be converted to the default display format for that type of data.  The characters that result may be displayed character by character according to the following codes:

String Code	Description
@	Displays remainder of converted data (whatever is not accounted for by the other code characters in the format string); input may be any chars.
_	Displays next char; input may only be one char.
n	Displays next char; input may only be a number.
a	Displays next char; input may only be an alphabetic char
u	Displays next char; input may only be a upper case letter.
l	Displays next char; input may only be a lower case letter.

An empty format string (where the length is zero) is treated as a "@".  This means that the cell's data is displayed in the default format for that type of data.

Boolean Codes

Boolean codes cause the cell's data to be treated as a Boolean value. A cell value of 0 is considered to be False or No, non-zero is True or Yes.  The following boolean codes may be specified for a column which has a data type of dttShortInt, dttLongInt, dttChar, dttUShortInt, or dttULongInt.

Boolean Code	Description
t	Displays T or F; input may be T or F.
tt	Displays True or False; input may be T or F.
y	Displays Y or N; input may be Y or N.
yy	Displays Yes or No; input may be Y or N.
Numeric Codes

The following numeric codes may be specified for a column which has a data type of  dttShortInt, dttLongInt, dttSingleFloat, dttDoubleFloat, dttChar, dttUShortInt, or dttULongInt.

Numeric Code	Displays
b	Display a blank cell when the cell value is 0.
#	Displays next digit, if available; input may be digit or null.
?	Displays next digit or space; input may be digit or space.
0	Displays next digit or zero; input must be digit, including zero.
-	(dash) Minus sign place holder, if appropriate.
+	Plus or minus sign place holder, as appropriate.
(	Parenthesis place holder, if appropriate.
)	Parenthesis place holder, if appropriate.
.	(period) Decimal point place holder.
,	(comma) Thousands separator place holder (not a digit place holder).

The international section of the WIN.INI file is used to determine the appropriate separators and format for numbers.  The international section of the WIN.INI file is set using the International icon found on the control panel.

Time Codes

The following time codes may be specified for a columns which has a data type of dttTime or dttDateTime.

Time Code	Displays
:	(colon) time separator place holder
h	1 digit hours ("1" through "12")
hh	2 digit hours ("01" through "12")
H	1 digit military hours ("0" through "23")
HH	2 digit military hours ("00" through "23")
m	1 digit minutes ("0" through "59")
mm	2 digit minutes ("00" through "59")
s	1 digit seconds ("0" through "59")
ss	2 digit seconds ("00" through "59")
s	seconds, if s or ss
f	fractional seconds, 1, 2, or 3 fs
P	A or P, as appropriate (note: for AM/PM, add a literal M)
p	a or p, as appropriate (note: for am/pm, add a literal m)

The international section of the WIN.INI file is used to determine the appropriate separators and format for time.  The international section of the WIN.INI file is set using the International icon found on the control panel.

Date Codes

The following date codes may be specified for a column which has a data type of dttDate or dttDateTime.

Date Code	Displays
/	(slash) date separator place holder
YY	2 digit year (1991 displays as "91", 1907 displays as "07")
YYYY	4 digit year
M	1 digit month number (Jan displays as "1", Oct displays as "10")
MM	2 digit month number (Jan displays as "01", Oct displays as "10")
MMM	month abbreviation (i. e.  "Jan", "Oct")
MMMM	full month name (i. e.  "January", "October")
D	1 digit Day number ("1" through "31")
DD	2 digit Day number ("01" through "31")
DDD	Day of Week abbreviation (i. e.  "Mon", "Sat")
DDDD	Day of Week (i. e.  "Monday", "Saturday")

The international section of the WIN.INI file is used to determine the appropriate separators and format for dates.  The international section of the WIN.INI file is set using the International icon found on the control panel.


Column Data

The following section describes column data types, data lengths, default values, and how to set and retrieve column data.

Column Data Types

Each column in a DataTable has an associated data type.

At design time, the data type for a column is specified using the Type field found on the Columns tab page.  At run time, use the DTColumn objects DataType property.

This data type is used to determine how a DataTable stores each row's data for that column.  Using a proper data type for a column can significantly improve a DataTable's performance.  The data type for a column is usually the same as the data type for the source/destination of the data.  If a program is going to perform a lot of calculations on the data in a column, it's best to pick an appropriate numeric data type even if the source/destination is string type data.

Column Data Length

Columns whose data type does not imply a certain amount of data storage must specifically set the data length.  Column data types with an variable length are dttString.

At design time enter the data length in the Len field box on the Columns tab page.  This edit box is only enabled for column with a variable data length.  At run time, use the DTColumn object DataLen property.

Column Default Values

Each column can have an associated default value.  The default value is used as the column value when an empty row is inserted.

There are several ways of inserting an empty row into the DataTable.  When auto row insert is enabled, an empty row is inserted into the DataTable whenever the user attempts to move past the end of the table and the last row is not empty.  When trapping the insert key, an empty row is inserted prior to the current row whenever the user presses the insert key.

At design time, the column default value is set using the Default Val field on the Columns tab page.  At run time use the DTColumn objects DefVal property.

Column Data Value

The data for a particular column can be retrieved or set using the DTColumn objects Value property.  This property is represented by a variant containg an array of variants.  The array has an element for each row.

Visual Basic Example

Dim ColData As Variant
ColData = Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
Datatbl1.ColumnSet(1).Value = ColData

Visual C++ Example

CDTData ColData;
// create a variant array  with 10 items
ColData.CreateArray(10);
for (i=0; i<10; i++)
ColData.PutItem( i, 0);
m_DataTbl.GetColumnSet().SetValue(ColData);


Column Searching

A column can be searched for a specified value using the DTColumn objects Search method.

This method takes two parameter, a variant specifying the item to search for and the index of the row to start the search after.  The index of the row where the item was found is returned.

To find the first item in the table, specify -1 as the row index to start the search after.

The following example searches the sixth column for all occurrences of SearchItem.  Whenever SearchItem is found, the value of the cell in the first column of the found row is added to Total.

Visual Basic Example

Dim Quantity As Integer
Dim Row As Long
Dim Total As Integer

Total = 0
' Search the column for the first row with the Search Item
Row = DataTbl1.ColumnSet(5).Search(SearchItem, -1)
While (Row >= 0)
Quantity = DataTbl1.CellSet(Row, 0).Value
' add the quantity to the total
Total = Total + Quantity
' continue the search
Row = DataTbl1.ColumnSet(5).Search(SearchItem, Row )
Wend

Visual C++ Example

CDTData varSearch= SearchItem;
CDTData var;
short Quantity, Total = 0;

CDTColumn SixthCol = m_dataTbl.GetColumnSet().GetItem(5);
// Search the sixth column for the first row with the Search Item
long Row= -1;
while ((Row=SixthCol.Search(varSearch,Row)) >=0)
{
// get the value of the first column in found row
var = m_dataTbl.GetCellSet().GetItem(Row, 0).GetValue();
// convert the value to a short
var.Get(&Quantity);
// add the Quantity to the total
Total+=Quantity;
}


Column Sorting

The rows of the DataTable can be re-organizes alphabetically or numerically using sort keys.  Up to three sort keys can be specified.  If more then one sort key is specified, rows with the same value for the first key are sorted according to the second and third keys.

Sort keys are specified by setting the DTColumnSet objects SortKey property.  Both ascending and descending sort directions are supported through the DTColumnSet objects SortAsc property.  The default sorting direction is ascending.  Sorting can be case insensitive by setting the DTColumnSet object SortCaseI property.  Changing any of the sorting information will re-sort the DataTable.

The first parameter to SortKey, SortAsc, and SortCaseI specifies the sort key.  The following table describes the possible settings.

Sort Key Constant	Sort Key
sortPrimary	Primary sort key
sortSecondary	Secondary sort key
sortTertiary	Tertiary sort key
Visual Basic Example

DataTbl1.ColumnSet.SortKey(sortPrimary) = 3
' disable the secondary sort key
DataTbl1.ColumnSet.SortKey(sortSecondary) = -1
' Set the sorting direction to descending
DataTbl1.ColumnSet.SortAsc(sortPrimary) = False

Visual C++ Example

m_dataTbl.GetColumnSet().SetSortKey(sortPrimary, 3);
// disable the secondary sort key
m_dataTbl.GetColumnSet().SetSortKey(sortSecondary, -1);
// sort descending
m_dataTbl.GetColumnSet().SetSortAsc(sortPrimary, FALSE);

Enabling and Disabling Sorting

Often it may be desirable to turn sorting off temporarily.  For example, if you set the SortKey property, the SortCaseI property, and then the SortAsc property, the DataTable will sort the table three times.  (Do this for all three sort keys and the DataTable will sort nine times!)  Another case where disabling sorting is beneficiary is when many values in a sort key column need to be updated.

Sorting is disabled and enabled using the DTColumnSet objects SortEnabled property.  Set this property to FALSE to disable sorting and TRUE to enable sorting.

Visual Basic Example

Datatbl1.ColumnSet.SortEnabled = False
 Set all sort information
Datatbl1.ColumnSet.SortEnabled = True

Visual C++ Example

m_dataTbl.GetColumnSet().SetSortEnabled (FALSE);
// Set all sort information
m_dataTbl.GetColumnSet().SetSortEnabled (TRUE);

Sorting effects

The DataTable remains sorted on the column designated to be the sort key.  As a result certain methods exhibit modified behavior.

The DTRowSet objects Add method ignores the insertion location when the table is sorted.  The DataTable inserts the row into a position so that the DataTable remains sorted.

The DTRowSet objects Copy method also ignores the new row index.  The new row index will always be one greater than the row being copied.

The DTRowSet objects Move method will generate an error on a sorted DataTable .  Moving a row would "un-sort" the table.

Updating or editing a cell in the sort key column will cause the row to move.  The row is moved to a position so that the table remains sorted..


Column Symbolic Names

Each column can have an associated symbolic name.  Symbolic names are useful when the column index of a particular column needs to be determined at run time.  For example, if it is possible for the user to move columns around, the programmer does not need to keep track of where a particular column is.

At design time, the symbolic name is set using the Name field on the Columns tab page.  At run time , use the DTColumn objects Name property.

Use the DTColumnSet objects GetColWithName method to retrieve the column index of the column with the specified symbolic name.  This method expects the symbolic name to be passed and returns the column index.

The DataTable informs its parent when the symbolic column name has changed by firing the ColNameChanged event.  This event row one parameter, the index of the column whose symbolic name changed.


Selecting Columns

The following section describes enabling column selection, the user interface to column selection, selecting columns, accessing selected columns, and column selection events.

Enabling Column Selection

Column selection is enabled at design time using the Selection tab page or at run time using the DTColumnSet objects SelectType property.  Set the SelectType property to selectNone to disable column selection, selectSingle to enable single column selection, or selectMultiple to enable multiple column selection.

The following example enables single column selection.

Visual Basic Example

Datatbl1.ColumnSet.SelectType = selectSingle

Visual C++ Example

m_DataTbl.GetColumnSet().SetSelectType(selectSingle);

User Interface to Column Selection

Once column selection is enabled, the user can select and deselect columns using the mouse or the keyboard.

The user can select or deselect a column by clicking the left mouse on a column heading.  The user can drag the selection or deselection by holding the left mouse button down and moving the mouse to a different column.

The user can select or deselect the current column by pressing CTRL+SPACE keys.  The user can drag the selection or deselection by pressing the SHIFT+left arrow or SHIFT+right arrow keys.

Selecting Columns

A particular column can be selected or deselected by setting the DTColumn objects Selected property.  Set this property to TRUE to select a column or FALSE to deselect a column.  The following example selects the sixth column.

Visual Basic Example

DataTbl.ColumnSet(5).Selected = True

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(5).SetSelected(TRUE);

In a multiple column selection table, a range of columns can be selected or deselected using the DTColumnSet objects SelectRange method.  This method takes three parameters: the index of first column in the range, the index of last column in the range, and a boolean flag specifying whether to select or deselect the columns in the range.  The following example selects the fifth through tenth column.

Visual Basic Example

DataTbl.ColumnSet.SelectRange 4, 9, True

Visual C++ Example

m_dataTbl.GetColumnSet().SelectRange (4, 9, TRUE);

The SelectRange method can also be used to selected or deselected all of the DataTable columns.  Specify 0 as the first column in the range and dtLast as the last column.

Accessing Selected Columns

To determine if a particular column is selected, use the DTColumn objects Selected property.  This property returns TRUE if the column is selected and FALSE if the column is not selected.

The DTColumnSet objects GetSelect method is used to retrieve the indexes of selected columns.  This method takes one parameter, the index of the column to start the search after.  To start the search at the beginning of the table specify -1.  The GetSelect method returns the index of the first selected column after the specified column.  If no selected column is found, this method returns a negative number.

In a single column selection table, the first selected column is the only selected column.  To retrieve the first selected column, call the DTColumnSet objects GetSelect method passing -1.  If no columns are selected, this call will return a negative number.

Visual Basic Example

SelectColumn% = DataTbl1.ColumnSet.GetSelect(-1)

Visual C++ Example

SelectColumn = m_dataTbl.GetColumnSet().GetSelect (-1);

To iterate though the selected column in a multiple selection table, first call the GetSelect method passing -1 to locate the first selected column.  If this method call returns a valid column index, repeatedly call GetSelect passing the value returned from the previous call until an invalid column index is returned.

Visual Basic Example

SelectColumn% = DataTbl1.ColumnSet.GetSelect(-1)
While (SelectColumn% >= 0)
 Process selected column
SelectColumn% = DataTbl1.ColumnSet.GetSelect (SelectColumn%)
Wend

Visual C++ Example

long SelectColumn = -1;
while ((SelectColumn = m_dataTbl.GetColumnSet().GetSelect (SelectColumn))>=0)
{
// Process selected column
}

Column Selection Events

The DataTable fires events when a column is selected or unselected..

Before a column is selected, the DataTable sends its parent a BeforeColumnSel event.  This event passes the index of the column being selected and a Status parameter.  The parent can prevent the column from being selected by setting the Status parameter to a non-zero value.

When a column is selected, the DataTable sends its parent a ColumnSel event.  This event passes the index of the column being selected.

When a column is deselected, the DataTable sends its parent a ColumnUnSel event.  This event passes the index of the column being unselected.


The Row Label Column

The DataTable can display a fixed column on the left side of the DataTable used to display row labels.

The type, if any, of row labels displayed is at design time using the Labels group box found on the Headings\Labels tab page.  At run time, use the DTColumnSet objects LabelType property.

The row label column should be treated like any other column.  A DTColumn object for the row label column is retrieved by using the DTColumnSet objects Item property and specifying dtLabelsColumn as the column index.

Visual Basic Example

Dim LabelCol As DTColumn
Set LabelCol = DataTbl1.ColumnSet(dtLabelsColumn)

Visual C++ Example

CDTColumn LabelCol = m_dataTbl.GetColumnSet().GetItem(dtLabelsColumn);

Setting the Row Label Column Width

The width of the row labels column is set in the same way as the width is set for any other column.

First retrieve a DTColumn object for the row labels column by using the DTColumnSet objects Item property and specifying dtLabelsColumn as the column index.  The DTColumn objects Width property can then be accessed.

Visual Basic Example

Dim LabelCol As DTColumn
Set LabelCol = DataTbl1.ColumnSet(dtLabelsColumn)
LabelCol.Width = 1000

Visual C++ Example

CDTColumn LabelCol = m_dataTbl.GetColumnSet().GetItem(dtLabelsColumn);
LabelCol.SetWidth(40);


Row Objects


Row Objects Overview

The DataTable uses the RowSet and DTRow objects to encapsulate properties and methods which affect the appearance and behavior of the DataTable rows.

The DTRowSet object encapsulates methods and properties which affect all DataTable rows. For example, the DTRowSet objects Height property represents the height of all DataTable rows.   The DTRowSet object is retrieved using the DataTable objects RowSet property.

Visual Basic Example

Dim RowSetObj As DTRowSet
Set RowSetObj = DataTbl1.RowSet

Visual C++ Example

CDTRowSet RowSetObj = m_dataTbl.GetRowSet()

The DTRow object encapsulates methods and properties which affect a particular row. For example, the DTRow objects Height property represents the height for a particular row.  A DTRow object is retrieved using the DTRowSet objects Item property and specifying the index of the row to retrieve.  (Rows are indexed starting at zero.)  The Item property is the default property, therefore Visual Basic programmers need not specify the property name.

Visual Basic Example

Dim RowObj As DTRow
 the following two lines are equivalent
Set RowObj = DataTbl1.RowSet.Item(RowIndex).Item
Set RowObj = DataTbl1.RowSet (RowIndex)

Visual C++ Example

CDTRow RowObj = m_dataTbl.GetRowSet().GetItem (RowIndex);


Manipulating DataTable Rows

The following section describes adding, copying, moving and removing rows from the DataTable.

Adding DataTable Rows

Adding Rows Programmatically

A row is added to the DataTable using the DTRowSet object's Add method.

The Add method takes two parameters: the destination location and the new row's data.

The destination location is specified by the index of row the new row is to be inserted prior to. To insert rows at the end of the table, specify the constant dtAfterLast as the destination.

The new row's data is specified by a vairant containg an array of variants.  Visual Basic customers can specify the row data by an array of variants rather than a variant containing an array of variants, which may be easier.   The following examples demonstrates the two different ways of passing row data.

Visual Basic Example

 Pass data as a variant containg an array of variants
Dim Data As Variant
Data = Array(Smith, 10000, 1)
Datatbl1.RowSet.Add dtAfterLast, Data

 pass data as an array of variants
Dim Data(0 To 2) As Variant
Data(0) = "Smith"
Data(1) = "25000"
Data(2) = True
Datatbl1.RowSet.Add dtAfterLast, Data

For Visual Basic programmers, the new rows data parameter is optional.  If new row data is not specified, an empty row is inserted.  Visual C++ programmers must specify an empty variant to insert an empty row.  The following example inserts an empty row at the end of the DataTable.

Visual Basic Example

 add an empty row after the last row
Datatbl1.RowSet.Add dtAfterLast

Visual C++ Example

// Add an empty row after the last row
CDTData Data;
m_dataTbl.GetRowSet().Add (dtAfterLast,  Data);

To add a new row to a DataTable immediately in front of the row with the input focus, retrieve the row index of the current cell using the DTCurCell object's Row property and then call the DTRowSet objects Add  method passing the current cells row index and the new row data.

Visual Basic Example

Dim Info(0 To 2) As Variant
Dim CurRow As Long

CurRow = Datatbl1.CurCell.Row
Info(0) = "Smith"
Info(1) = "25000"
Info(2) = True
Datatbl1.RowSet.Add CurRow, Info

Visual C++ Example

CDTData RowData;
// create a variant array with 3 items
RowData.CreateArray(3);
RowData.PutItem("Smith", 0);
RowData.PutItem(2500.00f, 1);
RowData.PutItem(1L, 2);
long CurRow = m_dataTbl.GetCurCell().GetRow();
m_dataTbl.GetRowSet().Add(CurRow, RowData);

Automatic Row Insert

The DataTable can be configured to automatically insert an empty row at the end of the table  This feature automatically inserts an empty row when the user tries to move past the end of the table and the last row is not empty.

At design time, enable this feature by checking the Auto Row Insert check box found on the Rows tab page.  At run time, use DTRowSet objects AutoRowInsert property.

Trapped Keys

The insert key can be used to insert an empty row.  The empty row is inserted prior to the current row.

At design time, enable this feature by checking the Trap Insert Key check box found on the Rows tab page.  At run time, use DTRowSet objects TrapInsertKey property.

Inserting Row Events

Before a row is inserted, the DataTable fires a BeforeInsert event.  This event passes two parameters, the index of the row the new row is inserted prior to and Status parameter.  The DataTable parent can prevent the row from being inserted by setting the Status parameter to a non zero value.

Once a row has been inserted, the DataTable fires an InsertedRow event.  This event passes one parameter, the index of the inserted row.

Coping Row Data

A row is copied in the DataTable using the DTRowSet objects Copy method.

The Copy method takes two parameters: the source and the destination.  The source is the index of the row to copy.  The destination is the index of the row the source row is copied prior to.  To copy a row to the end of the table, specify the constant dtAfterLast as the destination.

Existing rows will be bumped down as necessary to make room for the new row. For example, if the new row index is 4 and there are 16 rows, rows currently numbered 4 through 15 become rows 5 through 16 and the new row becomes row 4.  (Remember that rows are numbered starting at 0.)

Visual Basic Example

 Copy the first row after the last row.
Datatbl1.RowSet.Copy 0, dtAfterLast

Visual C++ Example

m_dataTbl.GetRowSet().Copy (0, dtAfterLast);

Moving Rows

A row is moved in the DataTable using the DTRowSet objects Move method.

The Move method takes two parameters: the source and the destination.  The source is the index of the row to move.  The destination is the index of the row the source row is moved prior to.  To move the row after the last row, specify the constant dtAfterLast as the destination.

Visual Basic Example

Datatbl1.RowSet.Move 0, dtAfterLast

Visual C++ Example

m_dataTbl.GetRowSet().Move (0, dtAfterLast);

Removing DataTable Rows

Removing All Row Information

To clear a DataTable of all row data, call the DTRowSet objects Reset method.  This method erases only the data.  The number of columns in the table, their sizes and types remain the same.

Visual Basic Example

DataTbl1.RowSet.Reset

Visual C++ Example

m_dataTbl.GetRowSet().Reset();

Removing a Particular Row

To remove a specific row, call the DTRowSet objects Remove method.  This method takes one parameter, the index of the row to remove.

To delete the current row, first retrieve the index of the current row using the DTCurCell objects Row  property.  Delete the current row by passing the returned index to the DTRowSet objects Remove method.

Visual Basic Example

CurRow = Datatbl1.CurCell.Row
DataTbl1.RowSet.Remove CurRow

Visual C++ Example

CurRow = m_dataTbl.GetCurCell().GetRow();
m_dataTbl.GetRowSet().Remove(CurRow);

Before a row is deleted, the DataTable fires a BeforeDeleteRow event.  This event passes two parameters, the index of the row to delete and the Status parameter.  The DataTable parent can prevent the row from being deleted by setting the Status parameter to a non zero value.

Once a row has been deleted, the DataTable fires a DeletedRow event.  This event passes one parameter, the index of the deleted row.


Row Appearance

The following section describes row colors, font, height, and vertical alignment.

Row Colors

The DTRow objects BackColor, ForeColor, SelBackColor, and SelForeColor properties are used to set and return the colors used when painting a particular row.

BackColor represents the row background color, ForeColor represents the row text color, SelBackColor represents the row background color for selected items, and SelForeColor represents the row text color for selected items.

The following example sets the background color and selected background color of the first row to gray.

Visual Basic Example

DataTbl1.RowSet(0).BackColor = RGB(192, 192, 192)
DataTbl1.RowSet(0).SelBackColor = RGB(192, 192, 192)

Visual C++ Example

m_dataTbl.GetRowSet().GetItem(0).SetBackColor(RGB(192,192,192));
m_dataTbl.GetRowSet().GetItem(0).SetSelBackColor(
RGB(192,192,192));

Color Priority

A cell can have overlapping color assignments.  For example, a particular cell can have a background color assigned to the cells row and a background color assigned to the cells column.  To resolve this problem, the DataTable uses the following list to decide which color assignment to use.

1.   Is this the current cell and has this current cell color been assigned?  Use the current cell color.

2.   Has this color been assigned to this cell?  Use the cell color.

3.   Has this color has been assigned to this row?  Use the row color.

4.   Has this color has been assigned to this column?  Use the column color.

5.   Use the DataTable color.

According to these rules, setting a row color will override the DataTable color and column color, but will not override the cell, or the current cell color.

Row Font

The font used when drawing a particular rows text is represented by the DTRow objects Font property.

Initially a font is not assigned to the row. Before any of the font properties can be accessed, a font object must be assigned

To assign a row font, Visual Basic customers need to create a font object by declaring a new StdFont object and then set the row Font property to the new object.

Dim X As New StdFont
 Set the font attributes
X.Name = MS Sans Serif
X.Bold = TRUE
X.Size = 12
Set Datatbl1.RowSet(0).Font = X

Visual C++ customers need to create a font dispatch pointer, create a COleFont property using the font dispatch pointer, and then set the Font  property to the new COleFont object.  The Microsoft function OleCreateFontIndirect can be used to create a font dispatch pointer.

LPDISPATCH pFontDisp = NULL;
// Set the font attributes
FONTDESC fontDesc = { sizeof(FONTDESC), OLESTR("MS Sans Serif"),
FONTSIZE(12), FW_NORMAL, DEFAULT_CHARSET, FALSE, FALSE,
FALSE };

// Create the font dispatch pointer
OleCreateFontIndirect((LPFONTDESC)&fontDesc, IID_IFont,
(LPVOID *)&pFontDisp);

// Create the Ole Font
COleFont *NewFont = new COleFont(pFontDisp);
m_dataTbl.GetRowSet().GetItem(0).SetFont(*NewFont);

Once a font has been assigned to a row, use the font Bold, Italic, Name, Size, StrikeThrough, Underline, and Weight properties to alter the row font.  The following example sets the first rows font objects Bold property to TRUE.

Visual Basic Example

DataTbl1.RowSet(0).Font.Bold = True

Visual C++ Example

m_dataTbl.GetRowSet().GetItem(0).GetFont.SetBold (TRUE);

To remove a previously assigned row font, Visual Basic programmers set the Font property to Nothing

DataTbl1.RowSet(0).Font = Nothing

and Visual C++ programmers set the Font property to NULL.

m_dataTbl.GetRowSet().GetItem(0).SetFont(NULL);

To determine if a font has been assigned to a row, Visual Basic programmers check if the Font property is Nothing

If (DataTbl1.RowSet(0).Font Is Nothing) Then

and Visual C++ programmers check if the Font property is NULL.

if (m_dataTbl.GetRowSet().GetItem(0).GetFont() == NULL)

Font Priority

A cell can have overlapping font assignments.  For example, a particular cell can have a font assigned to the cells row and a font assigned to the cells column.  To resolve this problem, the DataTable uses the following list to decide which font assignment to use.

1.   Is this the current cell and has a current cell font been assigned?  Use the current cell font.

2.   Has a font been assigned to this cell?  Use the cell font.

3.   Has a font has been assigned to this row?  Use the row font.

4.   Has a font has been assigned to this column?  Use the column font.

5.   Use the DataTable font.

According to the above rules, setting the row font will override the DataTable and column font, but will not override the cell, or the current cell font.

Row Height for All Rows

The height for all rows can be specified using the DTRowSet objects Height property.  The height is specified in the scale units of the DataTable's container.

Set the DTRowSet objects Height property to 0 to use a default height that is compatible with the DataTable font.

Visual Basic Example

Datatbl1.RowSet.Height = 400

Visual C++ Example

m_dataTbl.GetRowSet().SetHeight(30);

Vertical Text Alignment

The vertical alignment of text within the rows can be returned or set using the DTRowSet objects VertAlign property.  The possible settings are vertTop, vertCenter, and vertBottom.

Visual Basic Example

Datatbl1.RowSet.VertAlign = vertBottom

Visual C++ Example

m_dataTbl.GetRowSet().SertVertAlign(vertBottom);

Row Height for a Specific Row

The row height for a specific row is specified using the DTRow objects Height property.  The height is specified in the scale units of the DataTable's container.

Visual Basic Example

Datatbl1.RowSet(0).Height = 300

Visual C++ Example

m_dataTbl.GetRowSet().GetItem(0).SetHeight(30);

The DataTable informs its parent when a row has been resized by firing a RowSize event.  This event passes one parameter, the index of the row that was resized.


Row Data

Row data is set and returned using the DTRow objects Value property.

The data is returned in a variant containing an array of variants.  There is an item in the array for each column in the DataTable.

To retrieve a row based on the current position of the display cursor, first retrieve the DTRow object for the current row and then retrieve the row data using the DTRow objects Value property.

Visual Basic Example

Dim CurRow As Long

CurRow = Datatbl1.CurCell.Row
Data = Datatbl1.RowSet(CurRow).Value

Visual C++ Example

long CurRow = m_dataTbl.GetCurCell().GetRow();
m_DataTbl.GetRowSet().GetItem(CurRow).GetValue();


Selecting Rows

The following section describes enabling row selection, the user interface to row selection, selecting rows, accessing selected rows, and row selection events.

Enabling Row Selection

Row selection is enabled at design time using the Selection tab page or at run time using the DTRowSet objects SelectType property.  Set the SelectType property to selectNone to disable row selection, selectSingle to enable single row selection, or selectMultiple to enable multiple row selection.

The following example enables single row selection.

Visual Basic Example

Datatbl1.RowSet.SelectType = selectSingle

Visual C++ Example

m_DataTbl.GetRowSet().SetSelectType(selectSingle);

User Interface to Row Selection

Once row selection is enabled, the user can select and deselect rows using the mouse or the keyboard.

The user can select or deselect a row by clicking the left mouse on a row label.  The user can drag the selection or deselection by holding the left mouse button down and moving the mouse to a different row.

The user can select or deselect the current row by pressing SHIFT+SPACE keys.  The user can drag the selection or deselection by pressing the SHIFT+UP ARROW or SHIFT+DOWN ARROW keys.

Selecting Rows

A row can be selected or deselected by setting the DTRow objects Selected property.  Set this property to TRUE to select a row or FALSE to deselect a row.  The following example selects the sixth row.

Visual Basic Example

DataTbl.RowSet(5).Selected = True

Visual C++ Example

m_dataTbl.GetRowSet().GetItem(5).SetSelected(TRUE);

In a multiple row selection table, a range of rows can be selected or deselected using the DTRowSet objects SelectRange method.  This method takes three parameters: the index of first row in the range, the index of last row in the range, and a boolean flag specifying whether to select or deselect the rows in the range.  The following example selects the fifth through tenth row.

Visual Basic Example

DataTbl.RowSet.SelectRange 4, 9, True

Visual C++ Example

m_dataTbl.GetRowSet().SelectRange (4, 9, TRUE);

The SelectRange method can also be used to selected or deselected all of the DataTable rows.  Specify 0 as the first row in the range and dtLast as the last row.

Accessing Selected Rows

To determine if a particular row is selected, use the DTRow objects Selected property.  This property returns TRUE if the row is selected and FALSE if the row is not selected.

The DTRowSet objects GetSelect method is used to retrieve the indexes of selected rows.  This method takes one parameter, the index of the row to start the search after.  To start the search at the beginning of the table specify -1.  The GetSelect method returns the index of the first selected row after the specified row.  If no selected row is found, this method returns a negative number.

In a single row selection table, the first selected row is the only selected row.  To retrieve the first selected row, call the DTRowSet objects GetSelect method passing -1.  If no rows are selected, this call will return a negative number.

Visual Basic Example

SelectRow% = DataTbl1.RowSet.GetSelect (-1)

Visual C++ Example

SelectRow = m_dataTbl.GetRowSet().GetSelect (-1);

To iterate though the selected row in a multiple selection table, first call the GetSelect method passing -1 to locate the first selected row.  If this method call returns a valid row index, repeatedly call GetSelect passing the value returned from the previous call until an invalid row index is returned.

Visual Basic Example

SelectRow% = DataTbl1.RowSet.GetSelect (-1)
While (SelectRow% >= 0)
 Process selected row
SelectRow% = DataTbl1.RowSet.GetSelect (SelectRow%)
Wend

Visual C++ Example

long SelectRow = -1;
while ((SelectRow = m_dataTbl.GetRowSet().GetSelect (SelectRow))>=0)
{
// Process selected row
}

Row Selection Events

The DataTable fires events when a row is selected or unselected..

Before a row is selected, the DataTable sends its parent a BeforeRowSel event.  This event passes the index of the row being selected and a Status parameter.  The parent can prevent the row from being selected by setting the Status parameter to a non-zero value.

When a row is selected, the DataTable sends its parent a RowSel event.  This event passes the index of the row being selected.

When a row is deselected, the DataTable sends its parent a RowUnSel event.  This event passes the index of the row being unselected.


The Column Headings Row

The DataTable can display a fixed row on top of the DataTable used to display headings for the columns.

The type of column headings displayed, if any,  is set using the DTRowSet objects HeadingType property.  The DataTable supports letters, numbers and custom column headings.  If letters is chosen for the column headings, the column headings are labeled with letters starting with A and increasing.  If numbered column headings are specified, the columns are labeled with numbers starting at 1 and increasing.  Custom column headings allows the user to specify the column heading for each column.

The column headings DTRow object is retrieved by using the DTRowSet objects Item property and specifying a row index of dtHeadingsRow.

Visual Basic Example

Dim HeadRow As DTRow
Set HeadRow = DataTbl1.RowSet(dtHeadingsRow)

Visual C++ Example

CDTRow HeadRow = m_dataTbl.GetRowSet().GetItem(dtHeadingsRow);

The Column Headings Row Height

The Height property of the column headings DTRow object is used to represent the height of the column headings row.  This property returns the height of the headings row in the scale units of the DataTable's container.  Setting this property changes the height of the column headings row.  If this property is set to 0, the default height is used..

Visual Basic Example

Datatbl1.RowSet(dtHeadingsRow).Height = 300

Visual C++ Example

m_dataTbl.GetRowSet().GetItem(dtHeadingsRow).SetHeight(30);

Allowing the Column Headings Row to be Resized

The Resize property of the column headings DTRow object is used to represent whether the column headings row can be resized by the user.  The following example allows only the headings row to be resized by the user.

Visual Basic Example

DataTbl1.RowSet.AllowResize = False
Datatbl1.RowSet(dtHeadingsRow).Resize = resizeAdjustable

Visual C++ Example

m_dataTbl.GetRowSet().SetAllowResize(FALSE);
m_dataTbl.GetRowSet().GetItem(dtHeadingsRow).SetResize(resizeAdjustable);


Cell Objects


Cell Objects Overview

The DataTable uses the DTCellSet and DTCell objects to encapsulate properties and methods which affect the appearance and behavior of the DataTable cells.

The DTCellSet object encapsulates methods and properties which affect all DataTable cells.   The DTCellSet object is retrieved using the DataTable objects CellSet property.

Visual Basic Example

Dim CellSetObj As DTCellSet
Set CellSetObj = DataTbl1.CellSet

Visual C++ Example

CDTCellSet CellSetObj;
CellSetObj = m_dataTbl.GetCellSet()

The DTCell object encapsulates methods and properties which affect a particular cell.   A DTCell object is retrieved using the DTCellSet objects Item property and specifying the row and column index of cell to retrieve.   (Rows and columns are indexed starting at zero. )  The Item property is the default property, therefore Visual Basic programmers need not specify the property name.

Visual Basic Example

Dim CellObj As DTCell
 the following two lines are equivalent
Set CellObj = DataTbl1.CellSet.Item(RowIndex, ColIndex).Item
Set CellObj = DataTbl1.CellSet (RowIndex, ColIndex)

Visual C++ Example

CDTCell CellObj = m_dataTbl.GetCellSet().GetItem (RowIndex, ColIndex);


Cell Appearance

The following section describes cell colors and font.

Cell Colors

The DTCell objects BackColor, ForeColor, SelBackColor, and SelForeColor properties are used to set and return the colors used when painting a particular cell.

BackColor represents the cell background color, ForeColor represents the cell text color, SelBackColor represents the cell background color for selected items, and SelForeColor represents the cell text color for selected items.

The following example sets the background color and selected background color of the cell located in the first row and first column to gray.

Visual Basic Example

DataTbl1.CellSet(0, 0).BackColor = RGB(192, 192, 192)
DataTbl1.CellSet(0, 0).SelBackColor = RGB(192, 192, 192)

Visual C++ Example

m_dataTbl.GetCellSet().GetItem(0, 0).SetBackColor(RGB(192,192,192));
m_dataTbl.GetCellSet().GetItem(0, 0).SetSelBackColor(
RGB(192,192,192));

Color Priority

A cell can have overlapping color assignments.  For example, a particular cell can have a background color assigned to the cells row and a background color assigned to the cells column.  To resolve this problem, the DataTable uses the following list to decide which color assignment to use.

1.   Is this the current cell and has this current cell color been assigned?  Use the current cell color.

2.   Has this color been assigned to this cell?  Use the cell color.

3.   Has this color has been assigned to this row?  Use the row color.

4.   Has this color has been assigned to this column?  Use the column color.

5.   Use the DataTable color.

According to these rules, setting a cell color will override the DataTable, column, and row color, but will not override the current cell color.

Cell Font

The font used when drawing a particular cells text is represented by the DTCell objects Font property.

Initially a font is not assigned to the cell. Before any of the font properties can be accessed, a font object must be assigned

To assign a cell font, Visual Basic customers need to create a font object by declaring a new StdFont object and then set the cell Font property to the new object.

Dim X As New StdFont
 Set the font attributes
X.Name = MS Sans Serif
X.Bold = TRUE
X.Size = 12
Set Datatbl1.CellSet(0, 0).Font = X

Visual C++ customers need to create a font dispatch pointer, create a COleFont property using the font dispatch pointer, and then set the Font  property to the new COleFont object.  The Microsoft function OleCreateFontIndirect can be used to create a font dispatch pointer.

LPDISPATCH pFontDisp = NULL;
// Set the font attributes
FONTDESC fontDesc = { sizeof(FONTDESC), OLESTR("MS Sans Serif"),
FONTSIZE(12), FW_NORMAL, DEFAULT_CHARSET, FALSE, FALSE,
FALSE };

// Create the font dispatch pointer
OleCreateFontIndirect((LPFONTDESC)&fontDesc, IID_IFont,
(LPVOID *)&pFontDisp);

// Create the Ole Font
COleFont *NewFont = new COleFont(pFontDisp);
m_dataTbl.GetCellSet().GetItem(0, 0).SetFont(*NewFont);

Once a font has been assigned to a cell, use the font Bold, Italic, Name, Size, StrikeThrough, Underline, and Weight properties to alter the cell font.  The following example sets the cell located in the first row and first column font objects Bold property to TRUE.

Visual Basic Example

DataTbl1.CellSet(0, 0).Font.Bold = True

Visual C++ Example

m_dataTbl.GetCellSet().GetItem(0, 0).GetFont.SetBold (TRUE);

To remove a previously assigned cell font, Visual Basic programmers set the Font property to Nothing

DataTbl1.CellSet(0, 0).Font = Nothing

and Visual C++ programmers set the Font property to NULL.

m_dataTbl.GetCellSet().GetItem(0, 0).SetFont(NULL);

To determine if a font has been assigned to a cell, Visual Basic programmers check if the Font property is Nothing

If (DataTbl1.CellSet(0, 0).Font Is Nothing) Then

and Visual C++ programmers check if the Font property is NULL.

if (m_dataTbl.GetCellSet().GetItem(0, 0).GetFont() == NULL)

Font Priority

A cell can have overlapping font assignments.  For example, a particular cell can have a font assigned to the cells row and a font assigned to the cells column.  To resolve this problem, the DataTable uses the following list to decide which font assignment to use.

1.   Is this the current cell and has a current cell font been assigned?  Use the current cell font.

2.   Has a font been assigned to this cell?  Use the cell font.

3.   Has a font has been assigned to this row?  Use the row font.

4.   Has a font has been assigned to this column?  Use the column font.

5.   Use the DataTable font.

According to the above rules, setting the cell font will override the DataTable, column, and row font, but will not override the current cell font.


The Cell Data

The DTCell objects Value property is used to represent the value of a cell.  The value is represented by a variant.

The following example retrieves the value of the first two cells, multiplies the values, and assigns the result to the third column.

' read the QUANTITY cell in the row that was changed
Quantity = DataTbl1.CellSet(Row, 6).Value

' read the PRICE cell in the row that was changed
Price = DataTbl1.CellSet(Row, 7).Value

' update the TOTAL Column in the row that was changed
DataTbl1.CellSet(Row, 8).Value = Price * Quantity

Visual C++ Example

CDTData var;
short Quantity;
float Price;

// read the first cell in the row
var= m_dataTbl.GetCellSet().GetItem(Row, 0).GetValue();
// convert the value to a short
var.Get(&Quantity);

// read the second cell in the row
var = m_dataTbl.GetCellSet().GetItem(Row, 1).GetValue();
// convert the price value to a float
var.Get(&Price);

// the total price = quantity times price
Price *= Quantity;
// convert the floating point value back to a variant
var = Price;
// set the TOTAL cell value to the calculated total proce
m_dataTbl.GetCellSet().GetItem(Row, TOTAL).SetValue(var);


Null Cell Flagging

Often it is desired to specify a special value for a cell.  For example, data base applications that have cells with a NULL value.  NULL is an undefined value, it is not the same as zero.  Another example is cells that are "not applicable".  Because there is no value that can be used to represent a cell with a special value, a flag is used.

Use the DTCellSet objects NullString property to set the string used to represent cells with a null value.  By default, this string is set to NULL.

Use the DTCell objects NullFlag property to flag a cell has having a null value.

Cells can be flagged on or off by the user.  If the user enters the string used to represent a flagged cell while editing, that cell is marked as flagged.  Likewise, if a user changes the contents of a flagged cell to something other then the flagged cell string, the cell flag is turned off.


Selecting Blocks

The following section describes enabling block selection, the user interface to block selection, selecting blocks, accessing selected block, and block selection events.

Enabling Block Selection

Block selection is enabled at design time using the Selection tab page or at run time using the DTCellSet objects SelectType property.  Set the SelectType property to selectNone to disable block selection or selectSingle to enable block selection

The following example enables block selection.

Visual Basic Example

Datatbl1.CellSet.SelectType = selectSingle

Visual C++ Example

m_DataTbl.GetCellSet().SetSelectType(selectSingle);

User Interface to Block Selection

Once block selection is enabled, the user can select and deselect blocks using the mouse or the keyboard.

The user can select a block by clicking the left mouse on a cell.  The user can drag the selection by holding the left mouse button down while moving the mouse to a different row and column.

The user can drag the selection or deselection by pressing the SHIFT+arrow keys.

Selecting Blocks

A block can be selected or deselected by setting the DTCellSet objects SelectBlock method.  This method contains five parameters: the blocks left column, top row, right column and bottom row and a flag indicating whether the block is to be selected or deseleted.

Visual Basic Example

Datatbl1.CellSet.SelectBlock 0, 0, 2, 3, True

Visual C++ Example

m_dataTbl.GetCellSet().SelectBlock (0, 0, 2, 3, TRUE);

Accessing the Selected Block

To determine if a particular cell is in the selected block, use the DTCell objects Selected property.  This property returns TRUE if the cell is in the selected block and FALSE otherwise.

Visual Basic Example

If (Datatbl1.CellSet(0,0).Selected) Then
     cell is in the selected block
Else
     cell is not in the selected block

Visual C++ Example

if (m_dataTbl.GetCellSet().GetItem(0,0).GetSelected ())
// cell is in the selected block
else
// cell is not in the selected block

The DTCellSet objects GetSelect method is used to retrieve the selected block.  This method takes four parameters, left column, top row, right column and bottom row.  If a block is selected, this method returns TRUE and sets the left column, top row, right column and bottom row parameters.  If no selected block is found, this method returns FALSE.

Visual Basic Example

Dim left As Long, right As Long, top As Long, bottom As Long
If (Datatbl1.CellSet.GetSelect (left, top, right, bottom)) Then
     block selected.  left, top, right, and bottom specify selected block
Else
     No selection
End If

Visual C++ Example

long left, right, top, bottom;
if (m_dataTbl.GetCellSet().GetSelect (&left, &top, &right, &bottom))
// block selected.  left, top, right and bottom specify selected block
else
// no block selection

Block Selection Events

The DataTable fires events when a block is selected or unselected.

Before a block of cells is selected, the DataTable fires a BeforeBlockSel event.  This event passes the blocks left column, top row, right column and bottom row.  This event also passes a Status parameter.  The parent can prevent the block from being selected by setting the status parameter to a non-zero value.

When a block of cells is selected, the DataTable sends its parent a BlockSel event.  This event passes the selected blocks left column, top row, right column and bottom row.

When a block of cells is deselected, the DataTable sends its parent a BlockUnSel event. This event passes the deselected blocks left column, top row, right column and bottom row.


The Current Cell Object


The Current Cell Object Overview

The DataTable uses the DTCurCell object to encapsulate properties and methods which affect the current cell. The current cell is the cell with the input focus.  All editing is done on the current cell.

The DTCurCell object is retrieved using the DataTable objects CurCell property.

Visual Basic Example

Dim  cell As DTCurCell
Set cell = DataTbl1.CurCell

Visual C++ Example

CDTCurCell cell = m_dataTbl.GetCurCell()


The Current Cell Appearance

The following section describes the current cell colors, font, and focus rectangle.

Current Cell Colors

The DTCurCell objects BackColor, ForeColor, SelBackColor, and SelForeColor properties are used to set and return the colors used when painting the current cell.

BackColor represents the current cells background color, ForeColor represents the current cells text color, SelBackColor represents the current cells background color for selected items, and SelForeColor represents the current cells text color for selected items.

As the current cell changes, the color group moves to the new current cell.  Setting the DTCurCell objects color properties is not the same as setting the DTCell objects color properties for the current cell.  The DTCell objects color properties attaches the color group to a particular cell, therefore the color group would not move as the current cell changes.

The following example sets the background color and selected background color of the first column to gray.

Visual Basic Example

DataTbl1.CurCell.BackColor = RGB(192, 192, 192)
DataTbl1.CurCell.SelBackColor = RGB(192, 192, 192)

Visual C++ Example

m_dataTbl.GetCurCell().SetBackColor(RGB(192,192,192));
m_dataTbl.GetCurCell().SetSelBackColor(RGB(192,192,192));

Color Priority

A cell can have overlapping color assignments.  For example, a particular cell can have a background color assigned to the cells row and a background color assigned to the cells column.  To resolve this problem, the DataTable uses the following list to decide which color assignment to use.

1.   Is this the current cell and has this current cell color been assigned?  Use the current cell color.

2.   Has this color been assigned to this cell?  Use the cell color.

3.   Has this color has been assigned to this row?  Use the row color.

4.   Has this color has been assigned to this column?  Use the column color.

5.   Use the DataTable color.

According to these rules, setting a current cell color will override the DataTable, column, row, and cell color.

Current Cell Font

The font used when drawing the current cells text is represented by the DTCurCell objects Font property.

Initially a font is not assigned to the current cell. Before any of the font properties can be accessed, a font object must be assigned

To assign the current cell font, Visual Basic customers need to create a font object by declaring a new StdFont object and then set the Font property to the new object.

Dim X As New StdFont
 Set the font attributes
X.Name = MS Sans Serif
X.Bold = TRUE
X.Size = 12
Set Datatbl1.CurCell.Font = X

Visual C++ customers need to create a font dispatch pointer, create a COleFont property using the font dispatch pointer, and then set the Font  property to the new COleFont object.  The Microsoft function OleCreateFontIndirect can be used to create a font dispatch pointer.

LPDISPATCH pFontDisp = NULL;
// Set the font attributes
FONTDESC fontDesc = { sizeof(FONTDESC), OLESTR("MS Sans Serif"),
FONTSIZE(12), FW_NORMAL, DEFAULT_CHARSET, FALSE, FALSE,
FALSE };

// Create the font dispatch pointer
OleCreateFontIndirect((LPFONTDESC)&fontDesc, IID_IFont,
(LPVOID *)&pFontDisp);

// Create the Ole Font
COleFont *NewFont = new COleFont(pFontDisp);
m_dataTbl.GetCurCell().SetFont(*NewFont);

Once a font has been assigned to the current cell, use the font Bold, Italic, Name, Size, StrikeThrough, Underline, and Weight properties to alter the current cell font.  The following example sets the current cells font objects Bold property to TRUE.

Visual Basic Example

DataTbl1.CurCell.Font.Bold = True

Visual C++ Example

m_dataTbl.GetCurCell().GetFont.SetBold (TRUE);

To remove the previously assigned current cell font, Visual Basic programmers set the Font property to Nothing

DataTbl1.CurCell.Font = Nothing

and Visual C++ programmers set the Font property to NULL.

m_dataTbl.GetCurCell().SetFont(NULL);

To determine if a font has been assigned to the current cell, Visual Basic programmers check if the Font property is Nothing

If (DataTbl1.CurCell.Font Is Nothing) Then

and Visual C++ programmers check if the Font property is NULL.

if (m_dataTbl.GetCurCell().GetFont() == NULL)

Font Priority

A cell can have overlapping font assignments.  For example, a particular cell can have a font assigned to the cells row and a font assigned to the cells column.  To resolve this problem, the DataTable uses the following list to decide which font assignment to use.

1.   Is this the current cell and has a current cell font been assigned?  Use the current cell font.

2.   Has a font been assigned to this cell?  Use the cell font.

3.   Has a font has been assigned to this row?  Use the row font.

4.   Has a font has been assigned to this column?  Use the column font.

5.   Use the DataTable font.

According to the above rules, setting the current cell font will override the DataTable, column, row, and cell font.

The Focus Rectangle

The DataTable distinguishes the current cell from other cells by drawing a focus rectangle around the current cell.  The focus rectangle can be customized by using the DTCurCell objects FocusPenStyle, FocusPenWidth, and FocusPenColor properties.

The FocusPenStyle property specifies the focus rectangle drawing style.  It can be set to any one of the following values:

Constant	Meaning
fpDefault	Draw the default focus rectangle
fpSolid	Use a solid line.
fpDash	Use a dashed line. (Only valid when the focus pen width is 1.)
fpDot	Use a dotted line. (Only valid when the focus pen width is 1.)
fpDashDot	Use a line with alternating dashes and dots. (Only valid when the focus pen width is 1.)
fpDashDotDot	Use a line with alternating dashes and double dots  (Only valid when the focus pen width is 1.)
fpNull	Do not draw a focus rectangle
If FocusPenStyle is set to fpDefault, the DataTable draws a focus rectangle in the same style used to indicate that a button has focus.

The FocusPenWidth property specifies the pen width.  If the width is greater then 1, the pen style must be fpSolid.  This property is ignored if the pen style is fpDefault, or fpNull.

The FocusPenColor property specifies the color of the pen.  The color of the pen is NOT the color of the focus rectangle.  The color of the focus rectangle is a combination of the colors in the screen and the colors in the pen, but not in both.  This property is ignored if the pen style is fpDefault, or fpNull.


Editing the Current cell

The following section describes enabling editing, beginning, ending, and canceling editing, the selected text while editing, and edit events.

Enabling Editing

Editing is enabled at design time by checking the Editable checkbox found on the Current Cell tab page.  At run time, use the DTCurCell objects AllowCellEdit property.

The ability to edit when the current cell is in a particular column can be overridden Editable field on the Columns tab page and at run time use the DTColumn objects Editable property.

Beginning Editing

Editing of the current cell begins when the user presses the begin edit key.  The key used to begin editing can be returned or set using the DTCurCell objects KeyForBeginEdit property.  The begin edit key is the F2 key by default.

Editing can also be begun from within the program by calling the DTCurCell objects BeginEdit method.  This method takes no parameters.

The user pressing any character key also begins editing of the current cell and replaces the cell contents with that character.

Initially all characters in the cell are selected.

Ending Editing

Cell editing is ended and the edited value is accepted when the user presses the end edit key.   The key used to abort editing can be returned or set using the DTCurCell objects KeyForEndEdit property.  The end edit key is the ENTER key by default.

Other ways of ending edit mode can be enabled.  The following table describes the DTCurCell object properties that affect ending edit mode.

CurCell Property	Description
EndEditLfRtArrows	End edit with the left or right arrow key.
EndEditUpDnArrows	End edit with the up or down arrow key.
EndEditTab	End edit with the tab key.
EndEditCtrlTab	End edit with the CTRL+Tab key.
EndEditClick	End edit when the mouse is clicked on a different cell.

Editing can also be ended from within the program by calling the DTCurCell objects EndEdit  method.  This method takes no parameters

Canceling Editing

Editing of the current cell is canceled and the initial value restored when the user presses the abort edit key.  The key used to abort editing can be returned or set using the DTCurCell objects KeyForAbortEdit property.  The abort edit key is the ESCAPE key by default.

Editing can also be canceled from within the program by calling the DTCurCell objects AbortEdit method.

The Selected Text When Editing

The DTCurCell object contains two properties used to set the selected text while editing.

The DTCurCell objects SelStart property specifies the starting point of selected text and the SelLength property specifies the number of selected characters.

Specifying a SelLength of zero removes any current selection.  Setting the SelStart property sets the SelLength  property to 0.

Edit Events

When edit mode is initiated, either by the user or with the BeginEdit method, the DataTable first sends its parent window a BeforeBeginEdit event.  This event is sent to allow the parent to cancel edit mode by setting Status to non-zero.  If editing has begun, the DataTable send the parent a BeginEdit event.

If the user has entered as much data as will fit in the current cell, the DataTable sends its parent a CellFull event.  The cell being edited is specified by the row and Column parameters.

When edit mode is aborted, either by the user or with the AbortEdit method, the DataTable first sends its parent a BeforeAbortEdit event.  If Status is set to non-zero, editing is not aborted.  If editing is aborted, the DataTable sends its parent a AbortEdit event.

When edit mode is ended, either by the user or with the EndEdit method, the DataTable sends the parent a series of events.  First the parent sends a BeforeEndEdit event to allow the parent to prevent editing from being ended.  If editing is ended, the DataTable then sends its parent a Update event.  The Update event is sent before the DataTable has updated the cell contents.  The parent can read the original cell value at this time using the DTCurCell objects Value property.  The new cell value can be determined using the DTCurCell objects Value property.  Finally, a Change event is sent after the cell contents have been updated and editing has ended.  Reading the cell with a DTCurCell objects Value property at this time will return the new value.


The Current Cell Data

The value of the current cell can be accessing using the DTCurCell objects Value and EditValue property.  Both these properties specify the data using a variant.

The DTCurCell objects Value property represents the stored value for the current cell.

The DTCurCell objects EditValue property represents the value currently being entered into the current cell.  This property is only valid when the current cell is being edited.

The following example resets the edit value to the original value when the value being entered is less then zero.

Visual Basic Example

Price = DataTbl1.CurCell.EditValue
If (Price < 0) Then
' set the value in the edit box to the previous value
DataTbl1.CurCell.EditValue = DataTbl1.CurCell.Value
End If

Visual C++ Example

CDTData varPrice;
double price;

// fetch the DTCurCell object
CDTCurCell CurCell = m_dataTbl.GetCurCell();

// Read the value being entered into the edit box and convert the value to a double
varPrice= CurCell.GetEditValue();
varPrice.Get(&price);

if (price < 0)
{
// set the edit value to the old value
CurCell.SetEditValue( CurCell.GetValue() );
}


Moving the Current Cell

The current cells row, column, and pane index is represented by the DTCurCell objects Row, Column, and Pane properties.  As the current cell moves around the DataTable, these properties are updated.

When the current cell moves, the DataTable also notifies the parent by firing events.  The PosChange event is fired whenever the current cell changes.  This event passes the row and column index of the old current cell.  If the current row has changed, the DataTable will also fire a RowChange event passing the row index of the old current cell and if the current column has changed, the DataTable will also fire a ColChange event passing the column index of the old current cell.  While processing any of these positional events, the row and column index of the new current cell can be determined using the DTCurCell objects Row and Column properties.


The DataTable


Reference Guide


The DataTable Reference Guide Overview

The DataTable reference guide is composed of the following sections:

•	The DataTable Object Reference

•	The DTCurCell Object Reference

•	The DTColumnSet Object Reference

•	The DTColumn Object Reference

•	The DTRowSet Object Reference

•	The DTRow Object Reference

•	The DTCellSet Object Reference

•	The DTCell Object Reference

•	The Event Reference

 The DataTable Object Reference


The DataTable Object Properties

The following table lists the DataTable objects properties.

Property	Description
AboutBox Property	Displays an About dialog.
AllowPaintCellEvent Property	Returns/sets whether the PaintCell event is fired.
Appearance Property	Returns/sets the three dimensional effect drawn.
BackColor Property	Returns/sets the DataTable background color.
BorderStyle Property	Returns/sets the type of DataTable border drawn.
CellSet Property	Retrieves the DTCellSet object.
ColumnSet Property	Retrieves the DTColumnSet object.
CurCell Property	Retrieves the DTCurCell object.
DataSource Property
DropDownType Property	Returns/sets the drop down type.
DroppedState Property	Returns/sets whether the DataTable is fully visible
Enabled Property	Returns/sets whether the DataTable can respond to  user generated events.
Font Property	Returns/sets the DataTable font.
ForeColor Property	Returns/sets the DataTable text color.
GridLineColor Property	Returns/sets the color of the grid lines
HorzGridLines Property	Returns/sets whether horizontal grid lines are displayed.
HorzScrollBar Property	Returns/sets when scroll bars are displayed.
HorzSplitPane Property	Returns/sets whether the DataTable window is split horizontal.
hWnd Property	Returns a handle to the DataTable.
LeftPaneWidth Property	Returns/sets the width of the left pane.
Redraw Property	Enable or disable DataTable painting
RowSet Property	Retrieves the DTRowSet object.
SelBackColor Property	Returns/sets the selected background color.
SelForeColor Property	Returns/sets the selected text color.
TopPaneHeight Property	Returns/sets the height of the top pane.
VertGridLines Property	Returns/sets whether vertical grid lines are displayed.
VertScrollBar Property	Returns/sets when vertical scroll bars are displayed.
VertSplitPane Property	Returns/sets whether the DataTable window is split vertically.
VirtualMemType Property	Returns/sets the virtual memory type.
VMDataKey Property	Returns/sets the data key of the row being fetched while processing virtual memory events.


AboutBox Property

Displays the DataTable About dialog box.


AllowPaintCellEvent Property

Returns or sets whether the DataTable will fire the PaintCell event.

Syntax

Visual Basic

DataTbl.AllowPaintCellEvent = bEnabled

bEnabled = DataTbl.AllowPaintCellEvent

Visual C++

DataTbl.SetAllowPaintCellEvent ( bEnabled );

bEnabled  = DataTbl.GetAllowPaintCellEvent ();

The AllowPaintCellEvent property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
bEnabled	A boolean value specifying whether the DataTable fires the PaintCell event. (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	Allows the PaintCell event will fire.
False	Prevents the PaintCell event from firing.
Remarks

The PaintCell event is needed to implement owner drawn cells.

Examples

Visual Basic Example

DataTbl1.AllowPaintCellEvent= True

Visual C++ Example

m_dataTbl.SetAllowPaintCellEvent (TRUE);


Appearance Property

Returns or sets the three dimensional effect drawn.

Syntax

Visual Basic

DataTbl.Appearance = value

value = DataTbl.Appearance

Visual C++

DataTbl.SetAppearance ( value );

value = DataTbl.GetAppearance ();

The Appearance property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
value	An integer value specifying the type of three dimensional effect.  (Described in Settings)
Settings

The setting for value are:

Setting	Description
appearNone	None
appearHeavyIndent	Heavy Indent
appearShadow	Shadow
appearOutdent	Outdent
appearIndentFrame	Indent Frame
appearLightIndent	Light Indent
Examples

Visual Basic Example

DataTbl1.Appearance= appearShadow

Visual C++ Example

m_dataTbl.SetAppearance (appearShadow);


BackColor Property

Returns or sets the DataTable background color.

Syntax

Visual Basic

DataTbl.BackColor = color

color = DataTbl.BackColor

Visual C++

DataTbl.SetBackColor ( color );

color = DataTbl.GetBackColor ();

The BackColor property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
color	A long value specifying the DataTable background color.
Remarks

color can be either a RGB color or a system color constant.

Examples

Visual Basic Example

DataTbl1.BackColor= RGB(192, 192, 192)

Visual C++ Example

m_dataTbl.SetBackColor ( RGB(92, 192, 192) );


BorderStyle Property

Returns or sets the DataTable border style.

Syntax

Visual Basic

DataTbl.BorderStyle = value

value = DataTbl.BorderStyle

Visual C++

DataTbl.SetBorderStyle ( value );

value = DataTbl.GetBorderStyle ();

The BorderStyle property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
value	An integer value specifying the DataTable border style. (Described in Settings)
Settings

The setting for value are:

Setting	Description
ccNone	No Border drawn.
ccFixedSingle	Fixed Single border drawn.
Examples

Visual Basic Example

DataTbl1.BorderStyle= ccFixedSingle

Visual C++ Example

m_dataTbl.SetBorderStyle (ccFixedSingle);


CellSet Property

Returns the DTCellSet object..

Syntax

Visual Basic

DataTbl.CellSet

Visual C++

DataTbl.GetCellSet ( );

The CellSet property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
Remarks

The DTCellSet object encapsulates all properties and methods which affect cells.

Examples

Visual Basic Example

Dim CellSetObj As DTCellSet
Set CellSetObj = DataTbl1.CellSet

Visual C++ Example

CDTCellSet CellSetObj = m_dataTbl.GetCellSet();


ColumnSet Property

Returns the DTColumnSet object.

Syntax

Visual Basic

DataTbl.ColumnSet

Visual C++

DataTbl.GetColumnSet ( );

The ColumnSet property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
Remarks

The DTColumnSet object encapsulates all properties and methods which affects columns..

Examples

Visual Basic Example

Dim ColumnSetObj As DTColumnSet
Set ColumnSetObj = DataTbl1.ColumnSet

Visual C++ Example

CDTColumnSet ColumnSetObj = m_dataTbl.GetColumnSet();


CurCell Property

Returns the DTCurCell object.

Syntax

Visual Basic

DataTbl.CurCell

Visual C++

DataTbl.GetCurCell ();

The CurCell property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
Remarks

The DTCurCell object encapsulates all properties and methods which affect the current cell (the cell with the input focus).

Examples

Visual Basic Example

Dim CurCellObj As DTCurCell
Set CurCellObj = DataTbl1.CurCell

Visual C++ Example

CDTCurCell CurCellObj = m_dataTbl.GetCurCell ();


DataSource Property

Sets a value that specifies the Data control through which the DataTable is bound to a database.

Remarks

A DataTable is bound to a database by specifing a Data control in the DataSource property at design time using the Properties window.

A column in the DataTable is bound to a field in the Recordset object by setting the DTColumn objects Bound property to TRUE and Name property to the field name.

This property is not available at run time.


DropDownType Property

Returns or sets the DataTable drop down type.

Syntax

Visual Basic

DataTbl.DropDownType = value

value = DataTbl.DropDownType

Visual C++

DataTbl.SetDropDownType ( value);

value = DataTbl.GetDropDownType ();

The DropDownType property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
value	A integer value specifying the DataTable drop down type. (Described in Settings)
Settings

The setting for value are:

Setting	Description
ddNone	No Drop Down
ddDropDown	Drop Down
ddAutoDropDown	Auto Drop Down
Examples

Visual Basic Example

DataTbl1.DropDownType = ddAutoDropDown

Visual C++ Example

m_dataTbl.SetDropDownType(ddAutoDropDown);


DroppedState Property

Returns or sets whether the DataTable is fully visible

Syntax

Visual Basic

DataTbl.DroppedState = bState

bState = DataTbl.DroppedState

Visual C++

DataTbl.SetDroppedState ( bState );

bState = DataTbl.GetDroppedState ();

The DroppedState property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
bState	A boolean value specifying whether the DataTable is fully visible. (Described in Settings)
Settings

The setting for State are:

Setting	Description
True	DataTable is fully visible.
False	DataTable is in the closed up state.
Remarks

This property is useful when the DataTable DropDownType property is set to either ddDropDown or ddAutoDropDown.

Examples

Visual Basic Example

DataTbl1.DroppedState = True

Visual C++ Example

m_dataTbl.SetDroppedState (TRUE);


Enabled Property

Returns or sets whether the DataTable can respond to user-generated events.

Syntax

Visual Basic

DataTbl.Enabled = bEnabled

bEnabled = DataTbl.Enabled

Visual C++

DataTbl.SetEnabled ( bEnabled );

bEnabled = DataTbl.GetEnabled ();

The Enabled property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
bEnabled	A boolean value specifying whether the DataTable can respond to user generated events. (Described in Settings)
Settings

The setting for Enabled are:

Setting	Description
True	(Default) Allows DataTable to respond to events.
False	Prevents DataTable from responding to events.
Examples

Visual Basic Example

DataTbl1.Enabled = False

Visual C++ Example

m_dataTbl.SetEnabled (FALSE);


Font Property

Returns the DataTable Font object.

Syntax

Visual Basic

FontObj = DataTbl.Font

Visual C++

FontObj = DataTbl.GetFont ( );

Part	Description
DataTbl	A DataTable object.
FontObj	A font object specifying the DataTable font.
Examples

The following example sets the DataTable font to bold.

Visual Basic Example

DataTbl1.Font.Bold= True

Visual C++ Example

m_dataTbl.GetFont().SetBold (TRUE);


ForeColor Property

Returns or sets the DataTable foreground color.

Syntax

Visual Basic

DataTbl.ForeColor = color

color  = DataTbl.ForeColor

Visual C++

DataTbl.SetForeColor ( color );

color = DataTbl.GetForeColor ();

The ForeColor property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
color	A long value specifying the DataTable text color.
Remarks

color can be either a RGB color or a system color constant.

Examples

Visual Basic Example

DataTbl1.ForeColor= RGB(0,0,255)

Visual C++ Example

m_dataTbl.SetForeColor (RGB(0,0,255));


GridLineColor Property

Returns or sets the color of the grid lines.

Syntax

Visual Basic

DataTbl.GridLineColor = color

color = DataTbl.GridLineColor

Visual C++

DataTbl.SetGridLineColor ( color );

color = DataTbl.GetGridLineColor ();

The GridLineColor property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
color	A RGB color specifying the color used when drawing the grid lines
Examples

Visual Basic Example

DataTbl1.GridLineColor = RGB(0, 0, 0)

Visual C++ Example

m_dataTbl.SetGridLineColor (RGB(0,0,0));


HorzGridLines Property

Returns or sets whether the DataTable will draw horizontal grid lines.

Syntax

Visual Basic

DataTbl.HorzGridLines = bEnabled

bEnabled = DataTbl.HorzGridLines

Visual C++

DataTbl.SetHorzGridLines ( bEnabled );

bEnabled = DataTbl.GetHorzGridLines ();

The HorzGridLines property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
bEnabled	A boolean value specifying whether the DataTable will draw horizontal grid lines. (Described in Settings)
Settings

The setting for Enabled are:

Setting	Description
True	Horizontal grid lines are drawn between rows.
False	Horizontal grid lines are NOT drawn.
Examples

Visual Basic Example

DataTbl1.HorzGridLines = True

Visual C++ Example

m_dataTbl.SetHorzGridLines (TRUE);


HorzScrollBar Property

Returns or sets when the DataTable displays horizontal scroll bars.

Syntax

Visual Basic

DataTbl.HorzScrollBar = value

value  = DataTbl.HorzScrollBar

Visual C++

DataTbl.SetHorzScrollBar ( value );

value  = DataTbl.GetHorzScrollBar ();

The HorzScrollBar property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
value	An integer value specifying when DataTable displays horizontal scroll bars.  (Described in Settings)
Settings

The setting for value are:

Setting	Description
sbNone	The DataTable never displays horizontal scroll bars.
sbAutomatic	The DataTable displays a horizontal scroll bar when the total display width of the columns is greater then the size of the window.
sbAlwaysOn	The DataTable always displays horizontal scroll bars.
Examples

Visual Basic Example

DataTbl1.HorzScrollBar = sbAlwaysOn

Visual C++ Example

m_dataTbl.SetHorzScrollBar (sbAlwaysOn);


HorzSplitPane Property

Returns or sets whether the DataTable window is split horizontally.

Syntax

Visual Basic

DataTbl.HorzSplitPane = bEnabled

bEnabled = DataTbl.HorzSplitPane

Visual C++

DataTbl.SetHorzSplitPane ( bEnabled );

bEnabled = DataTbl.GetHorzSplitPane ();

The HorzSplitPane property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
bEnabled	A boolean value specifying whether the DataTable window is split horizontally. (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	The DataTable window is split horizontally
False	The DataTable window is NOT split horizontally
Examples

Visual Basic Example

DataTbl1.HorzSplitPane = True

Visual C++ Example

m_dataTbl.SetHorzSplitPane (TRUE);


hWnd Property

Returns a handle to the DataTable.

Syntax

Visual Basic

hwnd = DataTbl.hWnd

Visual C++

hwnd = DataTbl.GetHWnd ();

The hWnd property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
hwnd	A handle to the DataTable object
Remarks

The DataTable handle is needed when making Windows API calls.


LeftPaneWidth Property

Returns or sets the width of the left pane

Syntax

Visual Basic

DataTbl.LeftPaneWidth = value

value  = DataTbl.LeftPaneWidth

Visual C++

DataTbl.SetLeftPaneWidth ( value );

value  = DataTbl.GetLeftPaneWidth ();

The LeftPaneWidth property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
value	An integer value specifying the width of the left pane.  Use the constant dtMaxPaneSize to set the width to the maximum size.  The width is expressed in the scale units of the DataTables container.
Remarks

This property is only used when horizontal window splitting has been enabled.

Examples

Visual Basic Example

DataTbl1.LeftPaneWidth = 3000

Visual C++ Example

m_dataTbl.SetLeftPaneWidth (200);


Redraw Property

Returns or sets whether the DataTable repainting is enabled.

Syntax

Visual Basic

DataTbl.Redraw = bEnabled

bEnabled = DataTbl.Redraw

Visual C++

DataTbl.SetRedraw ( bEnabled );

bEnabled = DataTbl.GetRedraw ();

The Redraw property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
bEnabled	A boolean value specifying whether to enable or disable DataTable repainting.  (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	Repaint the screen when changes are made.
False	Do not update the screen when changes are made.
Remarks

The Redraw method is useful when adding a lot of data or when making several changes at once.

Examples

Visual Basic Example

DataTbl1.Redraw = False
 Insert many rows here
DataTbl1.Redraw =  True

Visual C++ Example

m_dataTbl.SetRedraw (FALSE);
// insert many rows here
m_dataTbl.SetRedraw (TRUE);


RowSet Property

Returns the DTRowSet object.

Syntax

Visual Basic

DataTbl.RowSet

Visual C++

DataTbl.GetRowSet ();

The RowSet property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
Remarks

The DTRowSet object encapsulates all properties and methods which affect the DataTable rows.

Examples

Visual Basic Example

Dim RowSetObj As DTRowSet
Set RowSetObj = DataTbl1.RowSet

Visual C++ Example

CDTRowSet RowSetObj = m_dataTbl.GetRowSet();


SelBackColor Property

Returns or sets the DataTable background color of selected items.

Syntax

Visual Basic

DataTbl.SelBackColor = color

color = DataTbl.SelBackColor

Visual C++

DataTbl.SetSelBackColor ( color );

color = DataTbl.GetSelBackColor ();

The SelBackColor property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
color	A long value specifying the DataTable background color for selected items.
Remarks

color can be either a RGB color or a system color constant.

Selected items include selected rows, columns, or blocks of cells.

Examples

Visual Basic Example

DataTbl1.SelBackColor= RGB(0,0,255)

Visual C++ Example

m_dataTbl.SetSelBackColor (RGB(0,0,255));


SelForeColor Property

Returns or sets the DataTable foreground color of selected items

Syntax

Visual Basic

DataTbl.SelForeColor = color

color = DataTbl.SelForeColor

Visual C++

DataTbl.SetSelForeColor ( color );

color = DataTbl.GetSelForeColor ();

The SelForeColor property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
color	A long value specifying the DataTable text color for selected items.
Remarks

color can be either a RGB color or a system color constant.

Selected items include selected rows, columns, or blocks of cells.

Examples

Visual Basic Example

DataTbl1.SelForeColor = RGB(255,255,255)

Visual C++ Example

m_dataTbl.SetSelForeColor (RGB(255,255,255));


TopPaneHeight Property

Returns or sets the height of the top pane.

Syntax

Visual Basic

DataTbl.TopPaneHeight = value

value = DataTbl.TopPaneHeight

Visual C++

DataTbl.SetTopPaneHeight ( value );

value = DataTbl.GetTopPaneHeight ();

The TopPaneHeight property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
value	An integer value specifying the height of the top pane.
Remarks

Use the constant dtMaxPaneSize to set the height to the maximum size.

The height is specified in the scale units of the DataTable's container.

This property is only used when vertical window splitting has been enabled.

Examples

Visual Basic Example

DataTbl1.TopPaneHeight = 2000

Visual C++ Example

m_dataTbl.SetTopPaneHeight (150);


VertGridLines Property

Returns or sets whether vertical grid lines are displayed.

Syntax

Visual Basic

DataTbl.VertGridLines = bEnabled

bEnabled  = DataTbl.VertGridLines

Visual C++

DataTbl.SetVertGirdLines ( bEnabled );

bEnabled  = DataTbl.GetVertGridLines ();

The VertGridLines property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
bEnabled	A boolean value specifying whether vertical grid lines are drawn.  (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	Vertical Grid lines are drawn.
False	Vertical Grid lines are NOT drawn.
Examples

Visual Basic Example

DataTbl1.VertGridLines = TRUE

Visual C++ Example

m_dataTbl.SetVertGridLines (True);


VertScrollBar Property

Returns or sets when the DataTable displays a vertical scroll bars.

Syntax

Visual Basic

DataTbl.VertScrollBar = value

value = DataTbl.VertScrollBar

Visual C++

DataTbl.SetVertScrollBar ( value );

value = DataTbl.GetVertScrollBar ();

The VertScrollBar property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
value	An integer value specifying when the DataTable shows the vertical scroll bars.  (Described in Settings)
Settings

The setting for value are:

Setting	Description
sbNone	The DataTable never displays vertical scroll bars.
sbAutomatic	The DataTable displays a vertical scroll bar when the total display height of the rows is greater then the size of the window.
sbAlwaysOn	The DataTable always displays vertical scroll bar.
Examples

Visual Basic Example

DataTbl1.VertScrollBar = sbAlwaysOn

Visual C++ Example

m_dataTbl.SetVertScrollBar (sbAlwaysOn);


VertSplitPane Property

Returns or sets whether the DataTable window is split vertically.

Syntax

Visual Basic

DataTbl.VertSplitPane = bEnabled

bEnabled  = DataTbl.VertSplitPane

Visual C++

DataTbl.SetVertSplitPane ( bEnabled );

bEnabled  = DataTbl.GetVertSplitPane ();

The VertSplitPane property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
bEnabled	A boolean value specifying whether the DataTable window is split vertically.  (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	The DataTable window is split vertically.
False	The DataTable window is NOT split vertically.
Examples

Visual Basic Example

DataTbl1.VertSplitPane = TRUE

Visual C++ Example

m_dataTbl.SetVertSplitPane (True);


VirtualMemType Property

Returns or sets the type of virtual memory model.

Syntax

Visual Basic

DataTbl.VirtualMemType = value

value = DataTbl.VirtualMemType

Visual C++

DataTbl.SetVirtualMemType ( value );

value = DataTbl.GetVirtualMemType ();

The VirtualMemType property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
value	An integer value specifying the type of virtual memory model used.  (Described in Settings)
Settings

The setting for value are:

Setting	Description
vmNone	No virtual memory model is used
vmIndexed	Virtual Memory with sequential keys
vmUserDefined	Virtual Memory with user defined keys.
Examples

Visual Basic Example

DataTbl1.VirtualMemType = vmIndexed

Visual C++ Example

m_dataTbl.SetVirtualMemType (vmIndexed);


VMDataKey Property

Returns or sets the data key of the virtual memory row being fetched.

Syntax

Visual Basic

DataTbl.VMDataKey = value

value = DataTbl.VMDataKey

Visual C++

DataTbl.SetVMDataKey( value );

value = DataTbl.GetVMDataKey ();

The VMDataKey property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
value	A long value specifying the data key of the fetched row.
Remarks

This property is should only be used while processing the virtual memory events.

Examples

Visual Basic Example

DataTbl1.VMDataKey = 10

Visual C++ Example

m_dataTbl.SetVMDataKey (10);


The DataTable Object Methods

The following table list the DataTable objects methods.

Method	Description
Reset Method	Reset all DataTable information
VMReady Method	Inform the DataTable that the parent is ready to receive virtual memory events
DBAutoConfig	Delete any existing columns and create a new column  for each field in the Recordset.


DBAutoConfig Method

Delete any existing columns and create a new column  for each field in the Recordset.

Syntax

Visual Basic

DataTbl.DBAutoConfig

The DBAutoConfig method syntax has these parts:

Part	Description
DataTbl	A DataTable object.
Remarks

This method first resets all DataTable information, including column and row information.  Any information currently stored in the DataTable is lost.

Examples

Visual Basic Example

DataTbl1.DBAutoConfig


Reset Method

Reset all DataTable information, including column and row information.

Syntax

Visual Basic

DataTbl.Reset

Visual C++

DataTbl.Reset ( );

The Reset method syntax has these parts:

Part	Description
DataTbl	A DataTable object.
Examples

Visual Basic Example

DataTbl1.Reset

Visual C++ Example

m_dataTbl.Reset ();


VMReady Method

Informs the DataTable that the parent is ready to process the virtual memory events.

Syntax

Visual Basic

DataTbl.VMReady numRows

Visual C++

DataTbl. VMReady ( numRows );

The VMReady method syntax has these parts:

Part	Description
DataTbl	A DataTable object.
numRows	A long value specifying the number of rows in the virtual memory table.  If the number of rows is unknown, specify 0.
Examples

Visual Basic Example

DataTbl1.VMReady 10000

Visual C++ Example

m_dataTbl.VMReady (10000);


The DTCurCell Object Properties

The following table list the DTCurCell objects properties.

Property	Description
AllowCellEdit Property	Returns/sets whether the current cell can be edited.
BackColor Property	Returns/sets the background color of the current cell.
Column Property	Returns/sets the column index of the current cell.
EditValue Property	Returns/sets the value while editing the current cell.
EndEditClick Property	Returns/sets whether edit mode is ended with a mouse click.
EndEditCtrlTab Property	Returns/sets whether edit mode is ended with the CTRL+TAB key.
EndEditLfRtArrows Property	Returns/sets whether edit mode is ended with the left and right arrow keys.
EndEditTab Property	Returns/sets whether edit mode is ended with the TAB key.
EndEditUpDnArrows Property	Returns/sets whether edit mode is ended with the up and down arrow keys.
FocusPenColor Property	Returns/sets the color of the pen used to draw the focus rectangle.
FocusPenStyle Property	Returns/sets the style used when drawing the focus rectangle.
FocusPenWidth Property	Returns/sets the width of the pen used when drawing the focus rectangle.
Font Property	Returns/sets the font used for the current cell.
ForeColor Property	Returns/sets the text color for the current cell.
hWndEditBox Property	Returns the handle to the edit box while editing.
hWndListBox Property	Returns the handle to the list box while editing.
KeyForAbortEdit Property	Returns/sets the key used to abort editing.
KeyForBeginEdit Property	Returns/sets the key used to begin editing.
KeyForEndEdit Property	Returns/sets the key used to end editing.
MoveColMajor Property	Returns/sets whether the next cell is determined by moving to the next row in the same column.
Pane Property	Returns/sets the pane number of the current cell.
Row Property	Returns/sets the row index of the current cell.
SelBackColor Property	Returns/sets the selected background color for the current cell.
SelForeColor Property	Returns/sets the selected text color for the current cell.
SelLength Property	Returns/sets the number of characters selected while editing.
SelStart Property	Returns/sets starting point of the text selected while editing.
TabToNextCell Property	Returns/sets whether the TAB key can be used to move to the next cell.
Value Property	Returns/sets the current cell value when not in edit mode.


AllowCellEdit Property

Returns or sets whether the DataTable will allow the current cell to be edited.

Syntax

Visual Basic

CurCell.AllowCellEdit = bEnabled

bEnabled  = CurCell.AllowCellEdit

Visual C++

CurCell.SetAllowCellEdit ( bEnabled );

bEnabled  = CurCell.GetAllowCellEdit ();

The AllowCellEdit property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
bEnabled	A boolean value specifying whether the DataTable will allow the current cell to be edited. (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	The current cell can be edited.
False	The current cell can not be edited.
Remarks

The ability to the current cell when it is in a particular column can be overridden by setting the DTColumn objects DataEdit property for that column.

Examples

The following examples enables the current cell to be edited.

Visual Basic Example

DataTbl1.CurCell.AllowCellEdit = True

Visual C++ Example

m_dataTbl.GetCurCell().SetAllowCellEdit (TRUE);


BackColor Property

Returns or sets the background color of the current cell

Syntax

Visual Basic

CurCell.BackColor = color

color = CurCell.BackColor

Visual C++

CurCell.SetBackColor ( color );

color = CurCell.GetBackColor ();

The BackColor property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
color	A long value specifying the current cell background color.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Examples

The following example sets the current cell background color to red.

Visual Basic Example

DataTbl1.CurCell.BackColor = RGB(255,0,0)

Visual C++ Example

m_dataTbl.GetCurCell().SetBackColor (RGB(255,0,0));


Column Property

Returns or sets the column index of the current cell

Syntax

Visual Basic

CurCell.Column = value

value = CurCell.Column

Visual C++

CurCell.SetColumn ( value );

value = CurCell.GetColumn ();

The Column property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
value	A long value specifying the column index of the current cell.
Remarks

Column indexes are zero based.

Examples

The following example retrieves the column index of the current cell.

Visual Basic Example

Col = DataTbl1.CurCell.Column

Visual C++ Example

m_dataTbl.GetCurCell().GetColumn ();

Sets a value that specifies the Data control through which the current control is bound to a database.  Not available at run time.


EditValue Property

Returns or sets the value being entered into the current cell while editing.

Syntax

Visual Basic

CurCell.EditValue = value

value = CurCell.EditValue

Visual C++

CurCelll.SetEditValue ( value );

value = CurCelll.GetEditValue ();

The EditValue property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
value	A variant value specifying the value being entered into the current cell while editing.
Remarks

This property is only valid while editing the current cell.

This property returns the value being entered into the current cell while editing.  To access the value of the cell while not in edit mode use the property Value.

Examples

The following example retrieves the value currently being entered into the current cell.  If this value is less then 0, the value being entered is changed to the original current cell value.

Visual Basic Example

 Read the value being entered into the edit box
Price = DataTbl1.CurCell.EditValue
If (Price < 0) Then
' set the value in the edit box to the previous value
DataTbl1.CurCell.EditValue = DataTbl1.CurCell.Value
End If

Visual C++ Example

CDTData varPrice;
double price;
// Read the value being entered into the edit box and convert the value to a double
varPrice= m_dataTbl.GetCurCell().GetEditValue();
varPrice.Get(&price);
if (price < 0)
{
// set the edit value to the previous value
m_dataTbl.GetCurCell().SetEditValue(m_dataTbl.GetCurCell().GetValue() );
}


EndEditClick Property

Returns or sets whether the DataTable will end edit mode with a mouse click on another cell.

Syntax

Visual Basic

CurCell.EndEditClick = bEnabled

bEnabled  = CurCell.EndEditClick

Visual C++

CurCell.SetEndEditClick ( bEnabled );

bEnabled  = CurCell.GetEndEditClick ();

The EndEditClick property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
bEnabled	A boolean value specifying whether the DataTable will end edit mode with a mouse click. (Described in Settings)
Settings

The setting for Enabled are:

Setting	Description
True	Allows edit mode to end with a mouse click.
False	Prevents edit mode from ending with a mouse click.
Examples

The following example enables edit mode to end when the user clicks on another DataTable cell.

Visual Basic Example

DataTbl1.CurCell.EndEditClick = True

Visual C++ Example

m_dataTbl.GetCurCell().SetEndEditClick (TRUE);


EndEditCtrlTab Property

Returns or sets whether the DataTable will end edit mode when the user presses the control tab key.

Syntax

Visual Basic

CurCell.EndEditCtrlTab = bEnabled

bEnabled  = CurCell.EndEditCtrlTab

Visual C++

CurCell.SetEndEditCtrlTab ( bEnabled );

bEnabled  = CurCell.GetEndEditCtrlTab ();

The EndEditCtrlTab property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
bEnabled	A boolean value specifying whether the DataTable will end edit mode when the users presses the control tab key. (Described in Settings)
Settings

The setting for Enabled are:

Setting	Description
True	Allows edit mode to end when the user presses the control tab key.
False	Prevents edit mode form ending when the user presses the control tab key.
Examples

The following example enables edit mode to end when the user presses the control tab key.

Visual Basic Example

DataTbl1.CurCell.EndEditCtrlTab = True

Visual C++ Example

m_dataTbl.GetCurCell().SetEndEditCtrlTab (TRUE);


EndEditLfRtArrows Property

Returns or sets whether the DataTable will end edit mode when the user presses the left or right arrow keys.

Syntax

Visual Basic

CurCell.EndEditLfRtArrows = bEnabled

bEnabled  = CurCell.EndEditLfRtArrows

Visual C++

CurCell.SetEndEditLfRtArrows ( bEnabled );

bEnabled  = CurCell.GetEndEditLfRtArrows ();

The EndEditLfRtArrows property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
bEnabled	A boolean value specifying whether the DataTable will end edit mode when the user presses the left or right arrow keys. (Described in Settings)
Settings

The setting for Enabled are:

Setting	Description
True	Allows edit mode to end when the users presses the left or right arrow keys.
False	Prevents edit mode from ending when the user presses the left or right arrow keys.
Examples

The following example enables edit mode to end when the user presses the left or right arrow keys.

Visual Basic Example

DataTbl1.CurCell.EndEditLfRtArrows = True

Visual C++ Example

m_dataTbl.GetCurCell().SetEndEditLfRtArrows (TRUE);


EndEditTab Property

Returns or sets whether the DataTable will end edit mode when the user presses the tab key.

Syntax

Visual Basic

CurCell.EndEditTab = bEnabled

bEnabled  = CurCell.EndEditTab

Visual C++

CurCell.SetEndEditTab ( bEnabled );

bEnabled  = CurCell.GetEndEditTab ();

The EndEditTab property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
bEnabled	A boolean value specifying whether the DataTable will end edit mode when the user presses the tab key. (Described in Settings)
Settings

The setting for Enabled are:

Setting	Description
True	Allows edit mode to end when the users presses the tab key.
False	Prevents edit mode from ending when the user presses the tab key.
Examples

The following example enables edit mode to end when the user presses the tab key.

Visual Basic Example

DataTbl1.CurCell.EndEditTab = True

Visual C++ Example

m_dataTbl.GetCurCell().SetEndEditTab (TRUE);


EndEditUpDnArrows Property

Returns or sets whether the DataTable will end edit mode when the user presses the up and down arrow keys.

Syntax

Visual Basic

CurCell.EndEditUpDnArrows = bEnabled

bEnabled  = CurCell.EndEditUpDnArrows

Visual C++

CurCell.SetEndEditUpDnArrows ( bEnabled );

bEnabled  = CurCell.GetEndEditUpDnArrows ();

The EndEditUpDnArrows property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
bEnabled	A boolean value specifying whether the DataTable will end edit mode when the user presses the up or down arrow keys. (Described in Settings)
Settings

The setting for Enabled are:

Setting	Description
True	Allows edit mode to end when the users presses the up or down arrow keys.
False	Prevents edit mode from ending when the user presses the up or down arrow keys.
Examples

The following example enables edit mode to end when the user presses the up or down arrow keys.

Visual Basic Example

DataTbl1.CurCell.EndEditUpDnArrows = True

Visual C++ Example

m_dataTbl.GetCurCell().SetEndEditUpDnArrows (TRUE);


FocusPenColor Property

Returns or sets the color of the pen used to draw the current cell focus rectangle.

Syntax

Visual Basic

CurCell.FocusPenColor = value

value = CurCell.FocusPenColor

Visual C++

CurCell.SetFocusPenColor( value );

value = CurCell.GetFocusPenColor ();

The FocusPenColor property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
value	A RGB color specifying the pen color.  This color is not the color of the focus rectangle.  The focus rectangle is the XOR of the pen and the screen color.
Remarks

The color of the pen is NOT the color of the focus rectangle.  The color of the focus rectangle is a combination of the colors in the screen and the colors in the pen, but not in both.  (An XOR operation)

This property is ignored if the FocusPenStyle property is fpDefault, or fpNull.

Examples

The following example sets the focus pen rectangle.

Visual Basic Example

Datatbl1.CurCell.FocusPenColor = RGB(255, 0, 0)
Datatbl1.CurCell.FocusPenStyle = fpSolid
Datatbl1.CurCell.FocusPenWidth = 2

Visual C++ Example

m_dataTbl.GetCurCell().SetFocusPenColor (RGB(255, 0, 0));
m_dataTbl.GetCurCell().SetFocusPenStyle (fpSolid);
m_dataTbl.GetCurCell().SetFocusPenWidth (2);


FocusPenStyle Property

Returns or sets the current cell focus rectangle drawing style.

Syntax

Visual Basic

CurCell.FocusPenStyle = value

value = CurCell.FocusPenStyle

Visual C++

CurCell.SetFocusPenStyle ( value );

value = CurCell.GetFocusPenStyle ();

The FocusPenStyle property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
value	A long value specifying the focus rectangle drawing style.  (Described in Settings)
Settings

The setting for value are:

Setting	Meaning
fpDefault	Draw the default focus rectangle
fpSolid	Use a solid line.
fpDash	Use a dashed line. (Only valid when the focus pen width is 1.)
fpDot	Use a dotted line. (Only valid when the focus pen width is 1.)
fpDashDot	Use a line with alternating dashes and dots. (Only valid when the focus pen width is 1.)
fpDashDotDot	Use a line with alternating dashes and double dots  (Only valid when the focus pen width is 1.)
fpNull	Do not draw a focus rectangle
If FocusPenStyle is set to fpDefault, the DataTable draws a focus rectangle in the same style used to indicate that a button has focus.

Examples

The following example sets the focus pen rectangle.

Visual Basic Example

Datatbl1.CurCell.FocusPenColor = RGB(255, 0, 0)
Datatbl1.CurCell.FocusPenStyle = fpSolid
Datatbl1.CurCell.FocusPenWidth = 2

Visual C++ Example

m_dataTbl.GetCurCell().SetFocusPenColor (RGB(255, 0, 0));
m_dataTbl.GetCurCell().SetFocusPenStyle (fpSolid);
m_dataTbl.GetCurCell().SetFocusPenWidth (2);


FocusPenWidth Property

Returns or sets the width of the pen used to draw the focus rectangle around the current cell.

Syntax

Visual Basic

CurCell.FocusPenWidth = value

value = CurCell.FocusPenWidth

Visual C++

CurCell.SetFocusPenWidth ( value );

value = CurCell.GetFocusPenWidth ();

The FocusPenWidth property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
value	An integer value specifying the focus pen width.
Remarks

If the width is greater then 1, the pen style must be fpSolid.  This property is ignored if the pen style is fpDefault, or fpNull.

Examples

The following example sets the focus pen rectangle.

Visual Basic Example

Datatbl1.CurCell.FocusPenColor = RGB(255, 0, 0)
Datatbl1.CurCell.FocusPenStyle = fpSolid
Datatbl1.CurCell.FocusPenWidth = 2

Visual C++ Example

m_dataTbl.GetCurCell().SetFocusPenColor (RGB(255, 0, 0));
m_dataTbl.GetCurCell().SetFocusPenStyle (fpSolid);
m_dataTbl.GetCurCell().SetFocusPenWidth (2);


Font Property

Returns or sets the font object used for the current cell.

Syntax

Visual Basic

Set CurCell.Font = FontObj

FontObj = CurCell.Font

Visual C++

CurCell.SetFont ( FontObj );

FontObj = CurCell.GetFont ( );

The Font property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
FontObj	A font object specifying the current cell font.
Remarks

Initially, no font is assigned to the current cell.  A font object must be assigned before the font properties can be accessed.

Visual Basic customers assign a font by declaring a new StdFont object and setting the Font property to the new object.

Visual C++ customers assign a font by creating a font dispatch pointer, creating a COleFont property from the font dispatch pointer, and setting the Font property to the new COleFont object.  The Microsoft function OleCreateFontIndirect can be used to create a font dispatch pointer.

Once a font has been assigned to the current cell, the font properties Bold, Italic, Name, Size, StrikeThrough, Underline, and Weight can be accessed.

Examples

The following example assigns a font to the current cell and then sets the current cell font bold property.

Visual Basic Example

Dim X As New StdFont
Set Datatbl1.CurCell.Font = X
Datatbl1.CurCell.Font.Bold = True

Visual C++ Example

LPDISPATCH pFontDisp = NULL;
// Create a font dispatch pointer
OleCreateFontIndirect(NULL, IID_IFont,(LPVOID *)&pFontDisp);
// Create the Ole Font
COleFont *NewFont = new COleFont(pFontDisp);
m_dataTbl.GetCurCell().SetFont(*NewFont);
m_dataTbl.GetCurCell().GetFont().SetBold (TRUE);


ForeColor Property

Returns or sets the foreground color of the current cell

Syntax

Visual Basic

CurCell.ForeColor = color

color = CurCell.ForeColor

Visual C++

CurCell.SetForeColor ( color );

color = CurCell.GetForeColor ();

The ForeColor property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
color	A long value specifying the current cell text color.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Examples

The following example sets the current cells text color to red.

Visual Basic Example

DataTbl1.CurCell.ForeColor = RGB(255, 0, 0)

Visual C++ Example

m_dataTbl.GetCurCell().SetForeColor (RGB(255,0,0));


hWndEditBox Property

Returns a handle to the edit box used while editing.

Syntax

Visual Basic

hwnd = DataTbl.hWndEditBox

Visual C++

hwnd = DataTbl.GetHWndEditBox ();

The hWndEditBox property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
hwnd	A handle to the edit box.
Remarks

This property is only valid while editing the current cell.

The edit box handle is needed when making Windows API calls.


hWndListBox Property

Returns a handle to the list box used while editing a column with a drop down list.

Syntax

Visual Basic

hwnd = DataTbl.hWndListBox

Visual C++

hwnd = DataTbl.GetHWndListBox ();

The hWndListBox property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
hwnd	A handle to the list box.
Remarks

This property is only valid while editing the current cell and the current cell contains a drop down list.

The list box handle is needed when making Windows API calls.


KeyForAbortEdit Property

Returns or sets the key used to abort edit.

Syntax

Visual Basic

CurCell.KeyForAbortEdit = value

value = CurCell.KeyForAbortEdit

Visual C++

CurCell.SetKeyForAbortEdit ( value );

value = CurCell.GetKeyForAbortEdit ();

The KeyForAbortEdit property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
value	An integer value specifying the virtual code of the key used to abort editing.
Examples

The following example specifies that the F1 key is to be used to abort editing of the current cell.

Visual Basic Example

DataTbl1.CurCell.KeyForAbortEdit = vbKeyF1

Visual C++ Example

m_dataTbl.GetCurCell().SetKeyForAbortEdit (VK_F1);


KeyForBeginEdit Property

Returns or sets the key used to begin editing the current cell.

Syntax

Visual Basic

CurCell.KeyForBeginEdit = value

value = CurCell.KeyForBeginEdit

Visual C++

CurCell.SetKeyForBeginEdit ( value );

value = CurCell.GetKeyForBeginEdit ();

The KeyForBeginEdit property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
value	An integer value specifying the virtual code of the key used to begin editing.
Examples

The following example specifies that the F1 key is to be used to begin editing of the current cell.

Visual Basic Example

DataTbl1.CurCell.KeyForBeginEdit = vbKeyF1

Visual C++ Example

m_dataTbl.GetCurCell().SetKeyForBeginEdit (VK_F1);


KeyForEndEdit Property

Returns or sets the key used to end editing of the current cell.

Syntax

Visual Basic

CurCell.KeyForEndEdit = value

value = CurCell.KeyForEndEdit

Visual C++

CurCell.SetKeyForEndEdit ( value );

value = CurCell.GetKeyForEndEdit ();

The KeyForEndEdit property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
value	An integer value specifying the virtual code of the key used to end editing of the current cell.
Examples

The following example specifies that the F1 key is to be used to end editing of the current cell.

Visual Basic Example

DataTbl1.CurCell.KeyForEndEdit = vbKeyF1

Visual C++ Example

m_dataTbl.GetCurCell().SetKeyForEndEdit (VK_F1);


MoveColMajor Property

Returns or sets how the DataTable moves to the next cell.

Syntax

Visual Basic

CurCell.MoveColMajor = bEnabled

bEnabled = CurCell.MoveColMajor

Visual C++

CurCell.SetMoveColMajor ( bEnabled );

bEnabled = CurCell.GetMoveColMajor ();

The MoveColMajor property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
bEnabled	A boolean value specifying how the DataTable moves to the next cell.  (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	Attempt to move to the next row before moving to the next column.  (Move row major)
False	Attempt to move to the next column before moving to the next row.  (Move column major)
Examples

The following example causes the DataTable to attempt to move the next column before moving to the next row.

Visual Basic Example

DataTbl1.CurCell.MoveColMajor = False

Visual C++ Example

m_dataTbl.GetCurCell().SetMoveColMajor (False);


Pane Property

Returns or sets the pane number of the current cell.

Syntax

Visual Basic

CurCell.Pane = value

value = CurCell.Pane

Visual C++

CurCell.SetPane ( value );

value = CurCell.GetPane ();

The Pane property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
value	An integer value specifying the pane number of the current cell.  (Described in Settings)
Settings

The setting for value are:

Constant	Meaning
paneLockedTop	Locked column pane, Top Pane
paneLeftTop	Left Pane, Top Pane
paneRightTop	Right Pane, Top Pane
paneLockedBottom	Locked column pane, Bottom Pane
paneLeftBottom	Left Pane, Bottom Pane
paneRightBottom	Right Pane, Bottom Pane
Examples

The following example retrieves the pane index of the current cell.

Visual Basic Example

Pane = DataTbl1.CurCell.Pane

Visual C++ Example

Pane = m_dataTbl.GetCurCell().GetPane();


Row Property

Returns or sets the row index of the current cell.

Syntax

Visual Basic

CurCell.Row = value

value = CurCell.Row

Visual C++

CurCell.SetRow ( value );

value = CurCell.GetRow ();

The Row property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
value	A long value specifying the row index of the current cell.
Remarks

Row indexes are zero based.

Examples

The following example retrieves the row index of the current cell.

Visual Basic Example

Row = DataTbl1.CurCell.Row

Visual C++ Example

Row = m_dataTbl.GetCurCell().GetRow;


SelBackColor Property

Returns or sets the background color of the current cell when selected.

Syntax

Visual Basic

CurCell.SelBackColor = color

color = CurCell.SelBackColor

Visual C++

CurCell.SetSelBackColor ( color);

color = CurCell.GetSelBackColor ();

The SelBackColor property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
color	A long value specifying the background color of the current cell when selected.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Selected items include selected rows, columns, or blocks of cells.

Examples

The following example sets the current cells selected background color.

Visual Basic Example

DataTbl1.CurCell.SelBackColor = RGB(0,0,255)

Visual C++ Example

m_dataTbl.GetCurCell().SetSelBackColor (RGB(0,0,255));


SelForeColor Property

Returns or sets the foreground color of the current cell when selected

Syntax

Visual Basic

CurCell.SelForeColor = color

color = CurCell.SelForeColor

Visual C++

CurCell.SetSelForeColor ( color );

color = CurCell.GetSelForeColor ();

The SelForeColor property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
color	A long value specifying  the text color of the current cell when selected.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Selected items include selected rows, columns, or blocks of cells.

Examples

The following example sets the current cells selected text color.

Visual Basic Example

DataTbl1.CurCell.SelForeColor = RGB(0,0,0)

Visual C++ Example

m_dataTbl.GetCurCell().SetSelForeColor (RGB(0,0,0));


SelLength Property

Returns or sets the number of characters selected while editing.

Syntax

Visual Basic

CurCell.SelLength = count

count  = CurCell.SelLength

Visual C++

CurCell.SetSelLength ( count );

count = CurCell.GetSelLength ();

The SelLength property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
count	A long value specifying the number of characters selected.
Remarks

This property is only valid while editing the current cell.

Examples

The following example traps the BeginEdit event and unselects the text.

Visual Basic Example

Private Sub Datatbl1_BeginEdit(ByVal Row As Long, ByVal Column As Long)
Datatbl1.CurCell.SelLength = 0
End Sub

Visual C++ Example

void CAcctMain::OnBeginEdit (long Row, long Column)
{
m_dataTbl.GetCurCell().SetSelLength (0);
}


SelStart Property

Returns or sets the starting point of selected text while editing.

Syntax

Visual Basic

CurCell.SelStart = index

index  = CurCell.SelStart

Visual C++

CurCell.SetSelStart ( index );

index = CurCell.GetSelStart ();

The SelStart property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
index	A long value specifying the starting point of selected text.
Remarks

This property is not available at design time.

This property is only valid while editing the current cell.

If SelStart  is set to a value greater the the length of the cell text, the start location to be set to the end of the text.

Setting the SelStart property causes the SelLength property to be set to 0.

Examples

The following example traps the BeginEdit event and sets the cursor to the end of the text.

Visual Basic Example

Private Sub Datatbl1_BeginEdit(ByVal Row As Long, ByVal Column As Long)
Datatbl1.CurCell.SelStart = 32000
End Sub

Visual C++ Example

void CAcctMain::OnBeginEdit (long Row, long Column)
{
m_dataTbl.GetCurCell().SetSelStart (32000);
}


TabToNextCell Property

Returns or sets whether the TAB key can be used to move to the next cell.

Syntax

Visual Basic

CurCell.TabToNextCell = bEnabled

bEnabled  = CurCell.TabToNextCell

Visual C++

CurCell.SetTabToNextCell ( bEnabled );

bEnabled  = CurCell.GetTabToNextCell ();

The TabToNextCell property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
bEnabled	A boolean value specifying whether the TAB key can be used to move to the next cell.  (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	The TAB key moves to the next cell and the CTRL+TAB key moves to the next control.
False	The TAB key moves to the next control and the CTRL+TAB key moves to the next cell.
Remarks

If the DTCurCell objects MoveColMajor property is set to FALSE, the DataTable will attempt to move to the next column before moving to the next row.  (This is the default behavior.)  If MoveColMajor is TRUE, the DataTable will attempt to move to the next row before moving to the next column.

To move to the previous cell press the shift key.

Examples

The following example enables the TAB key to be used to move to the next cell.

Visual Basic Example

DataTbl1.CurCell.TabToNextCell = True

Visual C++ Example

m_dataTbl.GetCurCell().SetTabToNextCell (TRUE);


Value Property

Returns or sets the value of the current cell.

Syntax

Visual Basic

CurCell.Value = value

value = CurCell.Value

Visual C++

CurCelll.SetValue ( value );

value = CurCell.GetValue ();

The Value property syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
value	A variant value specifying the value of the current cell.
Remarks

This property represents the value of the current cell when not in edit mode.  Use the property EditValue to access the value being entered while editng the current cell.

Examples

The following example retrieves the contents of the current cell.

Visual Basic Example

Dim Price As Double

Price = DataTbl1.CurCell.Value

Visual C++ Example

CDTData varPrice;
double price;

 // Read the current cell value and convert the value to a double
varPrice= m_dataTbl.GetCurCell().GetValue();
varPrice.Get(&price);


The DTCurCell Object Methods

The following table list the DTCurCell objects methods.

Method	Description
AbortEdit Method	Abort editing of the current cell.
BeginEdit Method	Begin editing of the current cell.
EndEdit Method	End editing of the current cell.
MoveToNext Method	Move the current cell to the next cell.
MoveToPrev Method	Move the current cell to the previous cell.


AbortEdit Method

Abort editing of the current cell and restore the previous value.

Syntax

Visual Basic

CurCell.AbortEdit

Visual C++

CurCell.AbortEdit ( );

The AbortEdit method syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
Remarks

This method is only valid while editing the current cell.

Examples

The following example aborts editing of the current cell.

Visual Basic Example

DataTbl1.CurCell.AbortEdit

Visual C++ Example

m_dataTbl.GetCurCell().AbortEdit ();


BeginEdit Method

Begin editing of the current cell.

Syntax

Visual Basic

CurCell.BeginEdit

Visual C++

CurCell.BeginEdit ( );

The BeginEdit method syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
Examples

The follwing example begins editing the current cell.

Visual Basic Example

DataTbl1.CurCell.BeginEdit

Visual C++ Example

m_dataTbl.GetCurCell().BeginEdit ();


EndEdit Method

End editing of the current cell and accept entered value.

Syntax

Visual Basic

CurCell.EndEdit

Visual C++

CurCell.EndEdit ( );

The EndEdit method syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
Remarks

This method is only valid while editing the current cell.

Examples

The following example ends editing of the current cell.

Visual Basic Example

DataTbl1.CurCell.EndEdit

Visual C++ Example

m_dataTbl.GetCurCell().EndEdit ();


MoveToNext Method

Move the current cell to the next cell.

Syntax

Visual Basic

CurCell.MoveToNext

Visual C++

CurCell.MoveToNext ( );

The MoveToNext method syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
Remarks

If the DTCurCell objects MoveColMajor property is set to FALSE, the DataTable will attempt to move to the next column before moving to the next row.  (This is the default behavior.)  If MoveColMajor is TRUE, the DataTable will attempt to move to the next row before moving to the next column.

Examples

The following example moves the current cell to the next cell.

Visual Basic Example

DataTbl1.CurCell.MoveToNext

Visual C++ Example

m_dataTbl.GetCurCell().MoveToNext ();


MoveToPrev Method

Move the current cell to the previous cell.

Syntax

Visual Basic

CurCell.MoveToPrev

Visual C++

CurCell.MoveToPrev ( );

The MoveToPrev method syntax has these parts:

Part	Description
CurCell	A DTCurCell object.
Remarks

If the DTCurCell objects MoveColMajor property is set to FALSE, the DataTable will attempt to move to the previous column before moving to the previous row. (This is the default behavior.)  If MoveColMajor is TRUE, the DataTable will attempt to move to the previous row before moving to the previous column.

Examples

The following example moves the current cell to the previous cell.

Visual Basic Example

DataTbl1.CurCell.MoveToPrev

Visual C++ Example

m_dataTbl.GetCurCell().MoveToPrev ();


The DTColumnSet Object Properties

The following table list the DTColumnSet objects properties.

Property	Description
AllowResize Property	Returns/sets whether columns can be resized.
Count Property	Returns/sets the number of columns.
FirstVisible Property	Returns/sets the first (left most) visible column.
HideListArrow Property	Returns/sets whether the arrow on a lest box column is visible.
Item Property	Returns the specified DTColumn object.
LabelType Property	Returns/sets the type of row labels displayed.
NumListItems Property	Returns/sets the number of items visible in a column which has a drop down list box.
SelectType Property	Returns/sets the column selection type.
SortAsc Property	Returns/sets the sorting direction.
SortCaseI Property	Returns/sets whether the sorting is case insensitive.
SortEnabled Property	Returns/sets whether sorting is enabled.
SortKey Property	Returns/sets the column used for sorting.


AllowResize Property

Returns or sets whether the columns can be resized by the user.

Syntax

Visual Basic

ColumnSet.AllowResize = bEnabled

bEnabled  = ColumnSet.AllowResize

Visual C++

ColumnSet.SetAllowResize ( bEnabled );

bEnabled  = ColumnSet.GetAllowResize ();

The AllowResize property syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
bEnabled	A boolean value specifying whether columns can be resized by the user.  (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	Allows DataTable columns to be resized.
False	Prevents DataTable columns from being resized.
Remarks

The ability to resize a particular column can be overridden using the DTColumn objects Resize property.

Examples

The following example enables columns to be resized by the user.

Visual Basic Example

DataTbl1.ColumnSet.AllowResize = True

Visual C++ Example

m_dataTbl.GetColumnSet().SetAllowResize (TRUE);


Count Property

Returns or sets the number of columns in the DataTable

Syntax

Visual Basic

ColumnSet.Count = value

value = ColumnSet.Count

Visual C++

ColumnSet.SetCount ( value );

value = ColumnSet.GetCount ();

The Count property syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
value	A long value specifying the number of columns.
Examples

The following example retrieves the number of columns in the DataTable.

Visual Basic Example

NumCols = DataTbl1.ColumnSet.Count

Visual C++ Example

NumCols = m_dataTbl.GetColumnSet().GetCount ();


FirstVisible Property

Returns or sets the index of the left most visible column in the specified pane.

Syntax

Visual Basic

ColumnSet.FirstVisible (LRPane) = value

value = ColumnSet.FirstVisible ( LRPane )

Visual C++

ColumnSet.SetFirstVisible ( LRPane, value );

value = ColumnSet.GetFirstVisible ( LRPane );

The FirstVisible property syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
LRPane	An integer value specifying which pane to set or retrieve the first visible column for.  (Described in Settings.)
value	A long value specifying the column index of the left most visible column.
Settings

The setting for LRPane are:

Setting	Description
paneLeft	Return or set the first visible column in the left pane.
paneRight	Return or set the first visible column in the right pane.
Remarks

If horizontal window splitting is not active, the only pane is the left pane.  Therefore, specify paneLeft in the LRPane parameter.

Columns are indexed starting at zero.

Examples

The following example scrolls the DataTable so that the third column is the left most visible column in the left pane.

Visual Basic Example

Datatbl1.ColumnSet.FirstVisible(paneLeft) = 2

Visual C++ Example

m_dataTbl.GetColumnSet().SetFirstVisible (paneLeft, 2);


HideListArrow Property

Returns or sets whether columns with a drop down list will hide the drop down arrow when the cell is not the current cell.

Syntax

Visual Basic

ColumnSet.HideListArrow = bEnabled

bEnabled  = ColumnSet.HideListArrow

Visual C++

ColumnSet.SetHideListArrow ( bEnabled );

bEnabled  = ColumnSet.GetHideListArrow ();

The HideListArrow property syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
bEnabled	A boolean value specifying whether to hide the drop down list arrow.  (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	Hide the drop down list arrow for all cells except for the current cell.
False	Always show the drop down list arrow.
Examples

The following example hides the column drop down list arrow.

Visual Basic Example

Datatbl1.ColumnSet.HideListArrow = True

Visual C++ Example

m_dataTbl.GetColumnSet().SetHideListArrow (TRUE);


Item Property

Retrieve a DTColumn object for the column specified.

Syntax

Visual Basic

ColumnSet.Item (index)

Visual C++

ColumnSet.GetItem ( index );

The Item property syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
index	A long value specifying the index of the column to retrieve.
Remarks

Columns are indexed starting at zero.

The Item property is the default property.  Therefore, in Visual Basic the following lines are equivalent.

DataTbl1.ColumnSet.Item(0)
DataTbl1.ColumnSet(0)

Examples

The following example retrieves the DTColumn object for the second column.

Visual Basic Example

Dim Col1 As DTColumn
Set Col1 = Datatbl1.ColumnSet(1)

Visual C++ Example

CDTColumn Col1 = m_dataTbl.GetColumnSet().GetItem (1);


LabelType Property

Returns or sets the type of row labels.

Syntax

Visual Basic

ColumnSet.LabelType = value

value = ColumnSet.LabelType

Visual C++

ColumnSet.SetLabelType ( value );

value = ColumnSet.GetLabelType ();

The GetLabelType property syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
value	An integer value specifying the type of row labels.  (Described in Settings)
Settings

The setting for value are:

Setting	Description
labelsNone	No row label are displayed
labelsCustom	Row buttons are displayed.
labelsNumbers	Rows are labeled with sequential numbers.
Examples

The following example sets the row labels to numbers.

Visual Basic Example

Datatbl1.ColumnSet.LabelType = labelsNumbers

Visual C++ Example

m_dataTbl.GetColumnSet().SetLabelType (labelsNumbers);


NumListItems Property

Returns or sets the number of items displayed in a drop down list box.

Syntax

Visual Basic

ColumnSet.NumListItems = value

value = ColumnSet.NumListItems

Visual C++

ColumnSet.SetNumListItems ( value );

value = ColumnSet.GetNumListItems ();

The NumListItems property syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
value	An integer value specifying the number of items to appear in the column drop down list box.
Examples

The following example sets the number of items in the drop down list boxes to 5.

Visual Basic Example

Datatbl1.ColumnSet.NumListItems= 5

Visual C++ Example

m_dataTbl.GetColumnSet().SetNumListItems (5);


SelectType Property

Returns or sets the type of column selection enabled

Syntax

Visual Basic

ColumnSet.SelectType = value

value = ColumnSet.SelectType

Visual C++

ColumnSet.SetSelectType ( value );

value = ColumnSet.GetSelectType ();

The GetSelectType property syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
value	An integer value specifying the type of column selection enabled.  (Described in Settings)
Settings

The setting for value are:

Setting	Description
selectNone	Disable column selection.
selectSingle	Enable single column selection.
selectMultiple	Enable multiple column selection
Examples

The following example enables multiple column selection.

Visual Basic Example

Datatbl1.ColumnSet.SelectType = selectMultiple

Visual C++ Example

m_dataTbl.GetColumnSet().SetSelectType (selectMultiple);


SortAsc Property

Returns or sets the sorting direction of the specified sort key.

Syntax

Visual Basic

ColumnSet.SortAsc (index) = bEnabled

bEnabled  = ColumnSet.SortAsc (index)

Visual C++

ColumnSet.SetSortAsc ( index, bEnabled );

bEnabled  = ColumnSet.GetSortAsc (index);

The SortAsc property syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
index	An integer value specifying which sort key the sorting direction is being returned or set for.  (Described in Settings)
bEnabled	A boolean value specifying the sorting direction.
Settings

The setting for index are:

Setting	Description
sortPrimary	Primary sort key
sortSecondary	Secondary sort key
sortTertiary	Tertiary sort key

The setting for bEnabled are:

Setting	Description
True	The sorting direction is ascending.
False	The sorting direction is descending.
Examples

The following example sets the sorting column, direction, and case sensitivity of the primary sort key.

Visual Basic Example

Datatbl1.ColumnSet.SortKey(sortPrimary) = 1
Datatbl1.ColumnSet.SortAsc(sortPrimary) = True
Datatbl1.ColumnSet.SortCaseI(sortPrimary) = True

Visual C++ Example

m_dataTbl.GetColumnSet().SetSortKey (sortPrimary, 1);
m_dataTbl.GetColumnSet().SetSortAsc (sortPrimary, TRUE);
m_dataTbl.GetColumnSet().SetSortCaseI (sortPrimary, TRUE);


SortCaseI Property

Returns or sets the whether the sort is case insensitive for the specified sort key.

Syntax

Visual Basic

ColumnSet.SortCaseI (index) = bEnabled

bEnabled  = ColumnSet.SortCaseI (index)

Visual C++

ColumnSet.SetSortCaseI ( index, bEnabled );

bEnabled  = ColumnSet.GetSortCaseI (index);

The SortCaseI property syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
index	An integer value specifying which sort key the sorting case sensitivity is being returned or set for.  (Described in Settings)
bEnabled	A boolean value specifying whether the sort is case insensitive.  (Described in Settings)
Settings

The setting for index are:

Setting	Description
sortPrimary	Primary sort key
sortSecondary	Secondary sort key
sortTertiary	Tertiary sort key

The setting for bEnabled are:

Setting	Description
True	The sort is case insensitive.
False	The sort is case sensitive.
Examples

The following example sets the sorting column, direction, and case sensitivity of the primary sort key.

Visual Basic Example

Datatbl1.ColumnSet.SortKey(sortPrimary) = 1
Datatbl1.ColumnSet.SortAsc(sortPrimary) = True
Datatbl1.ColumnSet.SortCaseI(sortPrimary) = True

Visual C++ Example

m_dataTbl.GetColumnSet().SetSortKey (sortPrimary, 1);
m_dataTbl.GetColumnSet().SetSortAsc (sortPrimary, TRUE);
m_dataTbl.GetColumnSet().SetSortCaseI (sortPrimary, TRUE);


SortEnabled Property

Returns or sets the whether sorting is enabled.

Syntax

Visual Basic

ColumnSet.SortEnabled = bEnabled

bEnabled  = ColumnSet.SortEnabled

Visual C++

ColumnSet.SetSortEnabled (bEnabled );

bEnabled  = ColumnSet.GetSortEnabled ();

The SortEnabled property syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
bEnabled	A boolean value specifying whether the sorting is enabled.  (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	Sorting is enabled.
False	Sorting is disabled.
Remarks

The SortEnabled property is used to temporarily turn sorting off.  This is adventageous when

Examples

The following example disables sorting, sets the sorting column, direction, and case sensitivity of the primary sort key, and then enables sorting.

Visual Basic Example

Datatbl1.ColumnSet.SortEnabled = False
Datatbl1.ColumnSet.SortKey(sortPrimary) = 1
Datatbl1.ColumnSet.SortAsc(sortPrimary) = True
Datatbl1.ColumnSet.SortCaseI(sortPrimary) = True
Datatbl1.ColumnSet.SortEnabled = True

Visual C++ Example

m_dataTbl.GetColumnSet().SetSortEnabled (FALSE);
m_dataTbl.GetColumnSet().SetSortKey (sortPrimary, 1);
m_dataTbl.GetColumnSet().SetSortAsc (sortPrimary, TRUE);
m_dataTbl.GetColumnSet().SetSortCaseI (sortPrimary, TRUE);
m_dataTbl.GetColumnSet().SetSortEnabled (TRUE);


SortKey Property

Returns or sets the columns used for sort keys

Syntax

Visual Basic

ColumnSet.SortKey = value

value = ColumnSet.SortKey

Visual C++

ColumnSet.SetSortKey ( value );

value = ColumnSet.GetSortKey ();

The SortKey property syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
index	An integer value specifying which sort key the column re.  (Described in Settings)
value	A long value specifying the index of the column to use as a sort key.
Settings

The setting for index are:

Setting	Description
sortPrimary	Primary sort key
sortSecondary	Secondary sort key
sortTertiary	Tertiary sort key
Examples

The following example sets the sorting column, direction, and case sensitivity of the primary sort key.

Visual Basic Example

Datatbl1.ColumnSet.SortKey(sortPrimary) = 1
Datatbl1.ColumnSet.SortAsc(sortPrimary) = True
Datatbl1.ColumnSet.SortCaseI(sortPrimary) = True

Visual C++ Example

m_dataTbl.GetColumnSet().SetSortKey (sortPrimary, 1);
m_dataTbl.GetColumnSet().SetSortAsc (sortPrimary, TRUE);
m_dataTbl.GetColumnSet().SetSortCaseI (sortPrimary, TRUE);


The DTColumnSet Object Methods

The following table list the DTColumnSet objects methods.

Method	Description
Add Method	Add a column to the DataTable.
Copy Method	Copy a column in the DataTable.
GetColWithName Method	Retrieve the index of the column with the specified symbolic name.
GetSelectCount Method	Retrieve the number of selected columns.
GetSelect Method	Retrieve the index of the first column selected after the specified column.
GetVisCount Method	Retrieve the number of visible columns.
Move Method	Move the specified column.
Remove Method	Remove the specified column.
SelectRange Method	Select a range of columns.


Add Method

Adds a column to the DataTable

Syntax

Visual Basic

ColumnSet.Add index

Visual C++

ColumnSet.Add ( index );

The Add method syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
index	An long value specifying the index of the column the new column is inserted prior to.
Remarks

Columns are indexed starting at zero.

To add a column to the end of the table, specify dtAfterLast in the index parameter.

Examples

The following inserts a column at the end of the table.

Visual Basic Example

Datatbl1.ColumnSet.Add dtAfterLast

Visual C++ Example

m_dataTbl.GetColumnSet().Add (dtAfterLast);


Copy Method

Copies a column.

Syntax

Visual Basic

ColumnSet.Copy source , dest

Visual C++

ColumnSet.Copy ( source, dest );

The Copy method syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
source	A long value specifying the index of the column to be copied.
dest	An long value specifying the index of the column the new column is inserted prior to.
Remarks

Columns are indexed starting at zero.

Specify the constant dtAfterLast in the dest parameter to copy a column to the end of the table.

Examples

The following example copies the first column to the end of the table

Visual Basic Example

Datatbl1.ColumnSet.Copy 0, dtAfterLast

Visual C++ Example

m_dataTbl.GetColumnSet().Copy (0, dtAfterLast);


GetColWithName Method

Returns the index of the column with the specified symbolic name.

Syntax

Visual Basic

index = ColumnSet.GetColWithName Name

Visual C++

index = ColumnSet.GetColWithName ( Name );

The GetColWithName method syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
Name	A string specifying the symbolic name.
index	A long value specifying the index of the column with the symbolic name
Remarks

Columns are indexed starting at zero.

Examples

The following example retrieves the index of the column with the symbolic name Income.

Visual Basic Example

Col = Datatbl1.ColumnSet.GetColWithName("Income")

Visual C++ Example

long Col = m_dataTbl.GetColumnSet().GetColWithName (Income);


GetSelectCount Method

Returns the number of columns selected in the DataTable.

Syntax

Visual Basic

Count = ColumnSet.GetSelectCount

Visual C++

Count = ColumnSet.GetSelectCount ( );

The GetSelectCount method syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
Count	A long value representing the number of selected columns.
Remarks

This method is only available if single or multiple column selection has been enabled.  (Column selection is enabled by setting the DTColumnSet objects SelectType property to selectSingle or selectMultiple.)

Examples

The following example retrieves the number of selected columns.

Visual Basic Example

Dim Count As Long
Count = Datatbl1.ColumnSet.GetSelectCount

Visual C++ Example

long Count = m_dataTbl.GetColumnSet().GetSelectCount ();


GetSelect Method

Returns the index of  the next selected column after the specified column.

Syntax

Visual Basic

next = ColumnSet.GetSelect index

Visual C++

next = ColumnSet.GetSelect ( index );

The GetSelect method syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
index	A long value specifying the index of the column to start search after.  Sepecify -1 to start the search at the beginning of the table.
next	A long value specifying the index of the next selected column after the specified column.
Remarks

This method is only available if single or multiple column selection has been enabled.  (Column selection is enabled by setting the DTColumnSet objects SelectType property to selectSingle or selectMultiple.)

Columns are indexed starting at zero.

Examples

The following example iterates thru the selected columns.

Visual Basic Example

' Get the column number of the first selected column
SelectCol = DataTbl1.ColumnSet.GetSelect(-1)
While (SelectCol>= 0)
        ' Process the selected olumn
        ' Get the Column number of the next selected Column
        SelectCol = DataTbl1.ColumnSet.GetSelect (SelectCol)
Wend

Visual C++ Example

// Get the index of the first selected Column
long SelectCol = -1;
while ((SelectCol = m_dataTbl.GetColumnSet().GetSelect (SelectCol))>=0)
{
// Process the selected column
m_dataTbl.GetCellSet().GetItem(SelectCol, STATUS).SetValue(var);
}


GetVisCount Method

Returns the number of visible columns in the specified pane.

Syntax

Visual Basic

count = ColumnSet.GetVisCount LRPane

Visual C++

count = ColumnSet.GetVisCount ( LRPane );

The GetVisCount method syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
LRPane	An integer specifying which pane to retrieve the number of visible columns for.  (Described in Settings.)
count	A long value specifying the number of visible columns.
Settings

The setting for index are:

Setting	Description
paneLeft	Return the number of visible columns in the left pane.
paneRight	Return the number of visible columns in the right pane.
Examples

The following example retrieves number of visible columns in the left pane.

Visual Basic Example

Dim Count As Long
Count = Datatbl1.ColumnSet.GetVisCount (paneLeft)

Visual C++ Example

long Count = m_dataTbl.GetColumnSet().GetVisCount (paneLeft);


Move Method

Moves a column in the DataTable.

Syntax

Visual Basic

ColumnSet.Move source, dest

Visual C++

ColumnSet.Move ( source, dest );

The Move method syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
source	A long value specifying the index of the column to move.
dest	A long value specifying the index of the column the source column is moved prior to.
Remarks

Columns are indexed starting at zero.

Specify the constant dtAfterLast in the dest parameter to move a column to the end of the table.

Examples

The following example moves the first column after the last column.

Visual Basic Example

Datatbl1.ColumnSet.Move 0, dtAfterLast

Visual C++ Example

m_dataTbl.GetColumnSet().Move (0, dtAfterLast);


Remove Method

Removes a column for the DataTable.

Syntax

Visual Basic

ColumnSet.Remove index

Visual C++

ColumnSet.Remove ( index );

The Remove method syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
index	A long value specifying the index of the column to be removed.
Remarks

Columns are indexed starting at zero.

Examples

The following example removes the first column.

Visual Basic Example

Datatbl1.ColumnSet.Remove 0

Visual C++ Example

m_dataTbl.GetColumnSet().Remove (0);


SelectRange Method

Selects or deselects a range of columns in the DataTable.

Syntax

Visual Basic

ColumnSet.SelectRange start, end, bSelect

Visual C++

ColumnSet.SelectRange ( start, end, bSelect );

The SelectRange method syntax has these parts:

Part	Description
ColumnSet	A DTColumnSet object.
start	A long value specifying the index of the first column in the range to select or deselect.
end	A long value specifying the index of the last column in the range to select or deselect.
bSelect	A boolean value specifying whether to select or deselect the columns in the range.  (Described in Settings)
Settings

The setting for bSelect are:

Setting	Description
True	Select the columns in the range.
False	Deselect the columns in the range.
Remarks

This method is only available if single or multiple column selection has been enabled.  (Column selection is enabled by setting the DTColumnSet objects SelectType property to selectSingle or selectMultiple.)

Columns are indexed starting at zero.

Examples

The following example selects the first thru the third column.

Visual Basic Example

Datatbl1.ColumnSet.SelectRange 0, 2

Visual C++ Example

m_dataTbl.GetColumnSet().SelectRange(0, 2);


The DTRowSet Object Properties

The following table list the DTRowSet objects properties.

Property	Description
AllowAutoRowInsert Property	Returns/sets whether rows will automatically be added to the end of the table.
AllowResize Property	Returns/sets whether rows can be resized.
Count Property	Returns/sets the number of rows in the DataTable.
FirstVisible Property	Returns/sets the inddex of the first (top most) visible row.
HeadingType Property	Returns/sets the type of column headings displayed.
Height Property	Returns/sets the height of the DataTable rows.
Item Property	Returns the specified DTRow object.
SelectType Property	Returns/sets the type of row selection enabled.
TrapDeleteKey Property	Returns/sets whether the delete key will delete the current row.
TrapInsertKey Property	Returns/sets whether the insert key will insert a new row.
VertAlign Property	Returns/sets the vertical alignment of text in rows.


AllowAutoRowInsert Property

Returns or sets whether the DataTable will automatically insert an empty row when the user attempts to move past the end of the table.

Syntax

Visual Basic

RowSet.AllowAutoRowInsert  = bEnabled

bEnabled = RowSet.AllowAutoRowInsert

Visual C++

RowSet.SetAllowAutoRowInsert ( bEnabled );

bEnabled = RowSet.GetAllowAutoRowInsert ();

The AllowAutoRowInsert property syntax has these parts:

Part	Description
DataTbl	A DataTable object.
bEnabled	A boolean value specifying whether empty row will automatically be inserted. (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	An empty row will be inserted.
False	An empty row will NOT be inserted.
Remarks

The newly inserted row contains the default values assigned to the columns.

A new row is inserted only if there are either no rows in the table or the last row is not empty.

A new row is inserted when either the user presses the down arrow when the current cell is in the last row or the user presses the CTRL+TAB key when the current cell is in the last row and last column of the table.

Examples

The following example enables rows to be added to the end of the table.

Visual Basic Example

DataTbl1.RowSet.AllowAutoRowInsert= True

Visual C++ Example

m_dataTbl.GetRowSet().SetAllowAutoRowInsert (TRUE);


AllowResize Property

Returns or sets whether DataTable rows can be resized by the user.

Syntax

Visual Basic

RowSet.AllowResize = bEnabled

bEnabled  = RowSet.AllowResize

Visual C++

RowSet.GetAllowResize ( bEnabled );

bEnabled  = RowSet.SetAllowResize ();

The AllowResize property syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
bEnabled	A boolean value specifying whether rows can be resized by the user.  (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	Allows DataTable rows to be resized.
False	Prevents DataTable rows from being resized.
Remarks

The ability to resize a particular row can be overridden using the DTRow objects Resize property.

Examples

The following example enables rows to be resized by the user.

Visual Basic Example

DataTbl1.RowSet.AllowResize= True

Visual C++ Example

m_dataTbl.GetRowSet().SetAllowResize (TRUE);


Count Property

Represents the number of rows in the DataTable

Syntax

Visual Basic

RowSet.Count = value

value = RowSet.Count

Visual C++

RowSet.SetCount ( value );

value = RowSet.GetCount ();

The Count property syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
value	A long value specifying the number of rows in the DataTable.
Remarks

When setting this property, rows are inserted or deleted from the end of the table until the number of rows in the DataTable equals value.

Examples

The following example iterates thru all rows in the DataTable.

Visual Basic Example

For i = 0 To DataTbl1.RowSet.Count - 1
 process row
Next i

Visual C++ Example

for (i=0; i< m_dataTbl.GetRowSet().GetCount();
{
// process row
}


FirstVisible Property

Returns or sets the index of the top most visible row in the specified pane.

Syntax

Visual Basic

RowSet.FirstVisible ( TBPane ) = value

value = RowSet.FirstVisible ( TBPane )

Visual C++

RowSet.SetFirstVisible ( TBPane, value );

value = RowSet.GetFirstVisible ( TBPane );

The FirstVisible property syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
TBPane	An integer value specifying which pane to return or set the first visible row for.  (Described in Settings.)
value	A long value specifying the index of the top most visible row.
Remarks

Rows are indexed starting at zero.

Settings

The setting for TBPane are:

Setting	Description
paneTop	Return or set the first visible row in the top pane.
paneBottom	Return or set the first visible row in the bottom pane.
Examples

The following example retrieves the index of the top most visible row.

Visual Basic Example

Dim TopRow As Long
TopRow = DataTbl1.RowSet.FirstVisible (paneTop)

Visual C++ Example

long TopRow = m_dataTbl.GetRowSet().GetFirstVisible (paneTop);


HeadingType Property

Returns or sets the type of column headings used.

Syntax

Visual Basic

RowSet.HeadingType = value

value = RowSet.HeadingType

Visual C++

RowSet.SetHeadingType ( value );

value = RowSet.GetHeadingType ();

The HeadingType property syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
value	An integer value specifying the type of column headings displayed.
Settings

The setting for value are:

Setting	Description
headingsNone	No column headings are displayed.
headingsLetters	Columns are labeled with letters
headingsNumbers	Columns are labeled with numbers
headingsCustom	Column headings are specified by the DTColumn objects Heading property.
Examples

The following example enables sets the column headings to numbers.

Visual Basic Example

DataTbl1.RowSet.HeadingType= headingsNumbers

Visual C++ Example

m_dataTbl.GetRowSet().SetHeadingType (headingsNumbers);


Height Property

Returns or sets the default height of the rows.

Syntax

Visual Basic

RowSet.Height = value

value = RowSet.Height

Visual C++

RowSet.SetHeight ( value );

value = RowSet.GetHeight ();

The Height property syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
value	An integer value specifying the default height of the rows.   The height is specified in the scale units of the DataTable's container.
Remarks

The height of a specific row can be specified using the DTRow objects Height property.

Examples

The following example sets the row height of all the rows.

Visual Basic Example

DataTbl1.RowSet.Height = 500

Visual C++ Example

m_dataTbl.GetRowSet().SetHeight (20);


Item Property

Returns a DTRow object for the row specified.

Syntax

Visual Basic

RowSet.Item ( index )

Visual C++

RowSet.GetItem ( index )

The Item property syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
index	A long value specifying the index of the row to return.
Remarks

Rows are indexed starting at zero.

This property is the default property.  Therefore, in Visual Basic the following two lines are equivilent.

DataTbl1.RowSet.Item(0)
DataTbl1.RowSet(0)

Examples

The following example retrieves the DTRow object for the first row.

Visual Basic Example

Dim Row0 As DTRow
Set Row0 = DataTbl1.RowSet(0)

Visual C++ Example

CDTRow Row0 = m_dataTbl.GetRowSet().GetItem (0);


SelectType Property

Returns or sets the type of row selection enabled.

Syntax

Visual Basic

RowSet.SelectType = value

value = RowSet.SelectType

Visual C++

RowSet.SetSelectType ( value );

value = RowSet.SetSelectType ();

The SelectType property syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
value	An integer value specifying the type of row selection enabled.  (Described in Settings)
Settings

The setting for value are:

Setting	Description
selectNone	Disable row selection.
selectSingle	Enable single row selection.
selectMultiple	Enable multiple row selection
Examples

The following example sets the row selection type to single selection.

Visual Basic Example

DataTbl1.RowSet.SelectType (selectSingle) = 0

Visual C++ Example

m_dataTbl.GetRowSet().SetSelectType (selectSingle);


TrapDeleteKey Property

Returns or sets whether the delete key is used to delete the current row.

Syntax

Visual Basic

RowSet.TrapDeleteKey= bEnabled

bEnabled  = RowSet.TrapDeleteKey

Visual C++

RowSet.SetTrapDeleteKey ( bEnabled );

bEnabled  = RowSet.GetTrapDeleteKey ();

The TrapDeleteKey property syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
bEnabled	A boolean value specifying whether the delete key is used to delete the current row.  (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	Allows the Delete key to be used to delete the current row.
False	Prevents the Delete key from being used to delete the current row.
Examples

The following examples enable the delete key to be used to delete rows.

Visual Basic Example

DataTbl1.RowSet.TrapDeleteKey = True

Visual C++ Example

m_dataTbl.GetRowSet().SetTrapDeleteKey (TRUE);


TrapInsertKey Property

Returns or sets whether the insert key is used to insert a new row.

Syntax

Visual Basic

RowSet.TrapInsertKey = bEnabled

bEnabled  = RowSet.TrapInsertKey

Visual C++

RowSet.SetTrapInsertKey ( bEnabled );

bEnabled  = RowSet.GetTrapInsertKey();

The TrapInsertKey property syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
bEnabled	A boolean value specifying whether the Insert key is used to insert a row prior to the current row.  (Described in Settings)
Settings

The setting for bEnabled are:

Setting	Description
True	Allows the Insert key to be used to insert a row.
False	Prevents the Insert key from being used to insert a row.
Remarks

The new row is inserted prior to the current row.

Examples

The following examples enable the insert key to be used to insert rows.

Visual Basic Example

DataTbl1.RowSet.TrapInsertKey = True

Visual C++ Example

m_dataTbl.GetRowSet().SetTrapInsertKey (TRUE);


VertAlign Property

Returns or sets the vertical alignment of data within rows

Syntax

Visual Basic

RowSet.VertAlign = value

value = RowSet.VertAlign

Visual C++

RowSet.SetVertAlign ( value );

value = RowSet.GetVertAlign ();

The VertAlign property syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
value	An integer value specifying the vertical alignment of data within rows.  (Described in Settings)
Settings

The setting for value are:

Setting	Description
vertTop	Align data to the top of the row.
vertCenter	Center data in the row.
vertBottom	Align data to the bottom of the row.
Examples

The following example enables sets the vertical alignment of row data to centered.

Visual Basic Example

DataTbl1.RowSet.VertAlign = vertCenter

Visual C++ Example

m_dataTbl.GetRowSet().SetVertAlign (vertCenter);


The DTRowSet Object Methods

The following table list the DTRowSet objects methods.

Method	Description
Add Method	Add a row to the DataTable.
Copy Method	Copy a row in the DataTable.
GetSelectCount Method	Retrieve the number of selected rows.
GetSelect Method	Retrieve the index of the first selected row after the specified row.
GetVisCount Method	Retrieve the number of visible rows.
Move Method	Move a row in the DataTable.
Remove Method	Remove a row from the DataTable.
Reset Method	Remove all DataTable rows.
SelectRange Method	Select a range of DataTable rows.


Add Method

Adds a row to the DataTable.

Syntax

Visual Basic

RowSet.Add index, data

Visual C++

RowSet.Add ( index, data );

The Add method syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
index	A long value specifying the index of the row the new row is inserted prior to.
data	(optional) A variant array specifying the new row data.
Remarks

Rows are indexed starting at zero.

To add a row to the end of the table, specify the constant dtAfterLast in the index parameter.

The data argument is an array of variants with an element for each column.

Visual C++ users must specify the data parameter.

Examples

The following example adds a row to the end of the table.  The table has three columns: a string, a real value, and a checkbox.

Visual Basic Example

Dim Info(0 To 2) As Variant

Info(0) = "Smith"
Info(1) = "25000"
Info(2) = True
Datatbl1.RowSet.Add dtAfterLast, Info

Visual C++ Example

CDTData RowData;
// create a variant array with 3 items
RowData.CreateArray(3);
RowData.PutItem("Smith", 0);
RowData.PutItem(2500.00f, 1);
RowData.PutItem(1L, 2);
m_dataTbl.GetRowSet().Add(dtAfterLast, RowData);


Copy Method

Copies the specified row.

Syntax

Visual Basic

RowSet.Copy source, dest

Visual C++

RowSet.Copy ( source, dest );

The Add method syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
source	A long value specifying the index of the row to copy.
dest	A long value specifying the index of the row the source row is inserted prior to.
Remarks

Rows are indexed starting at zero.

To copy a row to the end of the table, specify the constant dtAfterLast in the dest parameter.

Examples

The following example copies the first row to the end of the table.

Visual Basic Example

Datatbl1.RowSet.Copy 0, dtAfterLast

Visual C++ Example

m_dataTbl.GetRowSet().Copy(0, dtAfterLast);


GetSelectCount Method

Returns the number of selected rows.

Syntax

Visual Basic

count = RowSet.GetSelectCount

Visual C++

count = RowSet.GetSelectCount ( );

The GetSelectCount method syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
count	A long value specifying the number of selected rows.
Remarks

This method is only available if single or multiple row selection has been enabled.  (Row selection is enabled by setting the DTRowSet objects SelectType property to selectSingle or selectMultiple.)

Examples

The following example retrieves the number of selected rows.

Visual Basic Example

Dim Count As Long
Count = Datatbl1.RowSet.GetSelectCount

Visual C++ Example

long Count = m_dataTbl.GetRowSet().GetSelectCount ();


GetSelect Method

Returns the index of the next selected row after the specified row.

Syntax

Visual Basic

next = RowSet.GetSelect index

Visual C++

next = RowSet.GetSelect ( index );

The GetSelect method syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
index	A long value specifying the index of the row to start search after.  Specify -1 to start the search at the beginning of the table.
next	A long value specifying the index of the next selected row after the specified row.
Remarks

Rows are indexed starting at 0.

This method is only available if single or multiple row selection has been enabled.  (Row selection is enabled by setting the DTRowSet objects SelectType property to selectSingle or selectMultiple.)

Examples

The following example iterates through the selected rows.

Visual Basic Example

' Get the row number of the first selected row
SelectRow = DataTbl1.RowSet.GetSelect(-1)
While (SelectRow>= 0)
        ' Update the status Column
        DataTbl1.CellSet(SelectRow%, 0).Value = Hold.Picture
        ' Get the row number of the next selected row
        SelectRow = DataTbl1.RowSet.GetSelect (SelectRow)
Wend

Visual C++ Example

// Get the index of the first selected row
long SelectedRow = -1;
// Set the data to the bitmap handle
CDTData var = (LONG) pHandBitmap->m_hObject;
while ((SelectedRow = m_dataTbl.GetRowSet().GetSelect (SelectedRow))>=0)
{
// Set the value of the cell located in the SelectedRow, Status Column
m_dataTbl.GetCellSet().GetItem(SelectedRow, STATUS).SetValue(var);
// Get the index of the next selected Row
}


GetVisCount Method

Returns the number of visible rows in the specified pane.

Syntax

Visual Basic

count = RowSet.GetVisCount TBPane

Visual C++

count = RowSet.GetVisCount ( TBPane );

The GetVisCount method syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
TBPane	An integer specifying which pane to retrieve the number of visible rows for.  (Described in Settings)
count	A long value specifying the number of visible rows.
Settings

The setting for TBPane are:

Setting	Description
paneTop	Retrieve the number of visible rows in the top pane
paneBottom	Retrieve the number of visible rows in the bottom pane.
Examples

The following example retrieves the number of visible rows in the top pane.

Visual Basic Example

Dim Count As Long
Count = Datatbl1.RowSet.GetVisCount(paneTop)

Visual C++ Example

long Count = m_dataTbl.GetRowSet().GetVisCount (paneTop);


Move Method

Moves a row in the DataTable.

Syntax

Visual Basic

RowSet.Move source, dest

Visual C++

RowSet.Move ( source, dest);

The Move method syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
source	A long value specifying the index of the row to move.
dest	A long value specifying the index of the row the source row is moved prior to.
Remarks

Rows are indexed starting at 0.

Specify the constant dtAfterLast to move the row to the end of the table.

Examples

The following moves the first row after the last row.

Visual Basic Example

Datatbl1.RowSet.Move 0, dtAfterLast

Visual C++ Example

m_dataTbl.GetRowSet().Move (0, dtAfterLast);


Remove Method

Removes a row from the DataTable.

Syntax

Visual Basic

RowSet.Remove index

Visual C++

RowSet.Remove ( index);

The Remove method syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
index	A long value specifying the index of the row to remove.
Remarks

Rows are indexed starting at 0.

Examples

The following example deletes the second row.

Visual Basic Example

Datatbl1.RowSet.Remove 1

Visual C++ Example

m_dataTbl.GetRowSet().Remove (1);


Reset Method

Removes all DataTable rows.

Syntax

Visual Basic

RowSet.Reset

Visual C++

RowSet.Reset ( );

Examples

The following example removes all DataTable rows..

Visual Basic Example

Datatbl1.RowSet.Reset

Visual C++ Example

m_dataTbl.GetRowSet().Reset ();


SelectRange Method

Selects or deselects a range of rows in the DataTable.

Syntax

Visual Basic

RowSet.SelectRange start, end, bSelect

Visual C++

RowSet.SelectRange ( start, end, bSelect );

The SelectRange method syntax has these parts:

Part	Description
RowSet	A DTRowSet object.
start	A long value specifying the index of the first row in the range.
end	A long value specifying the index of the last row in the range
bSelect	A boolean value specifying whether the rows are selected or deselected.  (Described in Settings)
Settings

The setting for bSelect are:

Setting	Description
True	Select all the DataTable rows in the range.
False	Deselect all the DataTable rows in the range.
Remarks

This method is only available if single or multiple row selection has been enabled.  (Row selection is enabled by setting the DTRowSet objects SelectType property to selectSingle or selectMultiple.)

Examples

The following example selects the first three rows.

Visual Basic Example

Datatbl1.RowSet.SelectRange 0, 2

Visual C++ Example

m_dataTbl.GetRowSet().SelectRange (0, 2);


The DTCellSet Object Properties

The following table list the DTCellSet objects properties.

Property	Description
Item Property	Returns the specified DTCell object.
NullString Property	Returns/sets the string used to represent null cells.
SelectType Property	Returns/sets the type of cell selection enabled.


Item Property

Returns the DTCell object for the cell specified.

Syntax

Visual Basic

CellSet.Item ( Row, Column )

Visual C++

CellSet.GetItem ( Row, Column)

The Item property syntax has these parts:

Part	Description
CellSet	A DTCellSet object.
Row	A long value specifying the row index of the cell to return.
Column	A long value specifying the column index of the cell to return.
Remarks

Rows and columns are indexed starting at zero.

This property is the default property.  Therefore, in Visual Basic the following two lines are equivalent.

DataTbl1.CellSet.Item(0, 0)
DataTbl1.RowSet(0, 0)

Examples

The following example retrieves the DTCell object for the cell located in the first row, first column.

Visual Basic Example

Dim cell As DTCell
Set cell = DataTbl1.CellSet(0, 0)

Visual C++ Example

CDTCell cell = m_dataTbl.GetCellSet().GetItem (0, 0);


NullString Property

Returns or sets the string used to represent a null cell.

Syntax

Visual Basic

CellSet.NullString = value

value = CellSet.NullString

Visual C++

CellSet.SetNullString ( value );

value = CellSet.GetNullString ();

The NullString property syntax has these parts:

Part	Description
CellSet	A DTCellSet object.
value	A string value specifying the string to display and accept as input when the cell contains a null value
Examples

The following example sets the null cell string to be N/A.

Visual Basic Example

DataTbl1.CellSet.NullString = N/A

Visual C++ Example

m_dataTbl.GetCellSet().SetNullString(N/A);


SelectType Property

Returns or sets the type of block selection enabled.

Syntax

Visual Basic

CellSet.SelectType = value

value = CellSet.SelectType

Visual C++

CellSet.SetSelectType ( value );

value = CellSet.GetSelectType ();

The SelectType property syntax has these parts:

Part	Description
CellSet	A DTCellSet object.
value	An integer value specifying the type of block selection enabled.
Settings

The setting for value are:

Setting	Description
selectNone	Block selection is disabled.
selectSingle	Single block selection is enabled.
Examples

The following example enable single block selection.

Visual Basic Example

DataTbl1.CellSet.SelectType = selectSingle

Visual C++ Example

m_dataTbl.GetCellSet().SetSelectType (selectSingle);


The DTCellSet Object Methods

The following table list the DTCellSet objects methods.

Method	Description
GetCellAtPoint Method	Retrieves the pane, row, and column index of the cell located at the specified point.
GetSelect Method	Retrieves the selected block of cells.
SelectBlock Method	Selects a block of cells.


GetCellAtPoint Method

Retrieves the pane, row and column index of the cell located at the specified point.

Syntax

Visual Basic

ClickPos = CellSet.GetCellAtPoint ( X, Y, Pane, Row,Column )

Visual C++

ClickPos = CellSet.GetCellAtPoint ( X, Y, Pane, Row,Column );

The GetCellAtPoint method syntax has these parts:

Part	Description
CellSet	A DTCellSet object.
X	A floating point value specifying the horizontal position of the point.  The point is specified in the scale units of the DataTable's container.
Y	A floating point value specifying the vertical position of the point.  The point is specified in the scale units of the DataTable's container.
Pane	An integer variable used to return the pane index
Row	A long variable used to return the row index
Column	A long variable used to return the column index
ClickPos	A constant specifying the location where X,Y is.  (Described in Settings)
Settings

The settings for Pane are:

Constant	Meaning
paneLabelTop	Row label column, Top Pane
paneLockedTop	Locked column pane, Top Pane
paneLeftTop	Left Pane, Top Pane
paneRightTop	Right Pane, Top Pane
paneLabelBottom	Row label column, Bottom Pane
paneLockedBottom	Locked column pane, Bottom Pane
paneLeftBottom	Left Pane, Bottom Pane
paneRightBottom	Right Pane, Bottom Pane

The settings for ClickPos are:

Setting	Description
posOnCell	Within a cell.
posOnHeading	Within the row used to display column headings.
posOnLabel	Within the column used for row numbers of row selection buttons.
posOnColGridLine	On the grid line between 2 columns.
posOnRowGridLine	On the grid line between 2 rows
posOnVertPaneLine	On the pane line that splits the table vertically
posOnHorzPaneLine	On the pane line that splits the table horizontally
posNoWhere	Anywhere else within the client area of the DataTable.
Remarks

Rows and columns are indexed starting at zero.

Examples

The following example enable single block selection.

Visual Basic Example

Private Sub Datatbl1_MouseDown(Button As Integer, Shift As Integer,
X As Single, Y As Single)
Dim Column As Long, Row As Long, Pane As Integer, ClickPos As Integer
ClickPos = Datatbl1.CellSet.GetCellAtPoint(X, Y, Pane, Row, Column)
If (ClickPos = posOnCell) Then
 click was on a cell and Pane, Row, and Column have been set
End If
End Sub

Visual C++ Example

void OnMouseDownDatatblctrl1(short Button, short Shift, float x, float y)
{
long Column, Row;
short Pane;

short ClickPos = m_dataTbl.GetCellSet().GetCellAtPoint (x, y, &Pane,
&Row, &Column);
if (ClickPos == posOnCell)
{
// click was on a cell and Pane, Row, and Column have been set.
}
}


GetSelect Method

Retrieve the selected block.

Syntax

Visual Basic

bSuccess = CellSet.GetSelect ( LeftCol, TopRow, RightCol,
               BottomRow)

Visual C++

bSuccess = CellSet.GetSelect (LeftCol, TopRow, RightCol,
               BottomRow)

The GetSelect method syntax has these parts:

Part	Description
CellSet	A DTCellSet object.
LeftCol	A long variable used to return the index of the left most column in the block.
TopRow	A long variable used to return the index of the top most row in the block.
RightCol	A long variable used to return the index of the right most column in the block.
BottomRow	A long variable used to return the index of the bottom most row in the block.
bSuccess	A boolean value specifying whether a block of cells is currently selected.  (Described in Settings
Settings

The setting for bSuccess are:

Setting	Description
True	A block of cells is currently selected.  The block boundaries are return in the LeftCol, TopRow, RightCol, and BottomRow parameters.
False	A block of cells is not currently selected.
Remarks

This method is only available if single block selection has been enabled.  (Block selection is enabled by setting the DTCellSet objects SelectType property to selectSingle.)

Examples

The following example determines the selected block.

Visual Basic Example

Dim left As Long, right As Long, top As Long, bottom As Long
If (Datatbl1.CellSet.GetSelect (left, top, right, bottom)) Then
     block selected.  left, top, right, and bottom specify selected block
Else
     No selection
End If

Visual C++ Example

long left, right, top, bottom;
if (m_dataTbl.GetCellSet().GetSelect (&left, &top, &right, &bottom))
// block selected.  left, top, right and bottom specify selected block
else
// no block selection


SelectBlock Method

Select or deselect a block of cells.

Syntax

Visual Basic

CellSet.SelectBlock ( LeftCol, TopRow, RightCol, BottomRow,
                             bSelect)

Visual C++

CellSet.SelectBlock (LeftCol, TopRow, RightCol, BottomRow,
                             bSelect)

The SelectBlock method syntax has these parts:

Part	Description
CellSet	A DTCellSet object.
LeftCol	A long value specifying the index of the left most column in the block.
TopRow	A long value specifying the index of the top most row in the block.
RightCol	A long value specifying the index of the right most column in the block.
BottomRow	A long value specifying the index of the bottom most row in the block.
bSelect	A boolean value specifying whether the block is selected or deselected.  (Described in Settings)
Settings

The setting for bSelect are:

Setting	Description
True	Select the block of cells.
False	Deselect the block of cells.
Remarks

This method is only available if single block selection has been enabled.  (Block selection is enabled by setting the DTCellSet objects SelectType property to selectSingle.)

Columns and rows are indexed starting at zero.

Examples

The following example selects a block of cells.

Visual Basic Example

Datatbl1.CellSet.SelectBlock 0, 0, 2, 3, True

Visual C++ Example

m_dataTbl.GetCellSet().SelectBlock (0, 0, 2, 3, TRUE);


The DTColumn Object Properties

The following table list the DTColumn objects properties.

Property	Description
BackColor Property	Returns/sets the background color of the column.
Bound Property	Returns/sets whether the column is bound.
DataAlign Property	Returns/sets the alignment of the data in the column.
DataEdit Property	Returns/sets whether the column is editable.
DataLen Property	Returns/sets the length of the column data.
DataType Property	Returns/sets the type of the column data.
DefVal Property	Returns/sets the default value for the column.
EditAutoHScroll Property	Returns/sets whether the column data will scroll horizontally while editing the column.
EditAutoVScroll Property	Returns/sets whether the column data will sccroll vertically while editing the column.
EditLowercase Property	Returns/sets whether characters will be converted to lowercase while editing the column.
EditMultiLine Property	Returns/sets whether editing is multi-line for the column.
EditUppercase Property	Returns/sets whether characters will be converted to uppercase while editing the column.
EditWantReturn Property	Returns/sets whether the ENTER key can be used to move to the next line while editing the column.
Extra1 Property	Returns/sets the first extra long for the column.
Extra2 Property	Returns/sets the second extra long for the column.
Font Property	Returns/sets the font used for the column.
ForeColor Property	Returns or sets the text color used for the column.
Format Property	Returns/sets the format string used for the column.
HeadAlign Property	Returns/sets the heading alignment for the column.
Heading Property	Returns/sets the heading string for the column.
Hidden Property	Returns/sets whether the column is hidden.
List Property	Returns/sets the list of items used for a drop down list.
Locked Property	Returns/sets whether the column is locked.
Name Property	Returns/sets the symbolic name for the column.
Overwrite Property	Returns/sets whether cells in the column can overwrite adjoining cells.
Resize Property	Returns/sets whether the column can be resized.
SelBackColor Property	Returns/sets the selected background color for the column.
Selected Property	Returns/sets whether the column is selected.
SelForeColor Property	Returns/sets the selected text color for the column.
Value Property	Returns/sets the value of the cells in the column.
Width Property	Returns/sets the column width.


BackColor Property

Returns or sets the background color of the column.

Syntax

Visual Basic

Column.BackColor = color

color = Column.BackColor

Visual C++

Column.SetBackColor ( color );

color = Column.GetBackColor ();

The BackColor property syntax has these parts:

Part	Description
Column	A DTColumn object.
color	A long value specifying the column background color.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Examples

The following example sets the background color for the first column.

Visual Basic Example

Datatbl1.ColumnSet(0).BackColor = RGB(255, 0, 0)

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetBackColor (RGB(255, 0, 0));


Bound Property

Returns or sets whether the column is bound to a field in the Recordset.

Syntax

Visual Basic

Column.Bound = bEnabled

bEnabled = Column.Bound

The Bound property syntax has these parts:

Part	Description
Column	A DTColumn object.
bEnabled	A boolean value specifying whether the column is bound to a field in the RecordSet.
Settings

The setting for bEnabled are:

Setting	Description
True	The column is bound.
False	The column is not bound.
Examples

The following example binds the first column to a field in the Recordset called StudentID.

Visual Basic Example

Datatbl1.ColumnSet(0).Bound = True
Datatbl1.ColumnSet(0).Name = StudentID

Remarks

This property is only used by a bound DataTable.

A DataTable is bound to a database by specifying a Data control in the DataSource property at design time using the Properties window.

A column in the DataTable is bound to a field in the Recordset object by setting the DTColumn objects Bound property to TRUE and Name property to the field name.


DataAlign Property

Returns or sets the data alignment for the column.

Syntax

Visual Basic

Column.DataAlign = value

value = Column.DataAlign

Visual C++

Column.SetDataAlign ( value );

value = Column.GetDataAlign ();

The DataAlign property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	An integer specifying the data alignment for the column.  (Described in Settings)
Settings

The setting for value are:

Setting	Description
horzLeft	Left align the data.
horzCenter	Center the data.
horzRight	Right align the data.
Examples

The following example sets the data aligment of the first column to centered.

Visual Basic Example

Datatbl1.ColumnSet(0).DataAlign = horzCenter

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetDataAlign (horzCenter);


DataEdit Property

Returns or sets whether the data in the column is editable.

Syntax

Visual Basic

Column.DataEdit = value

value = Column.DataEdit

Visual C++

Column.SetDataEdit ( value );

value = Column.GetDataEdit ();

The DataEdit property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	An integer value specifying whether the data in the column is editable.  (Described in Settings)
Settings

The setting for value are:

Setting	Description
editDefault	(Default) The column data is editable if the DTCurCell objects Editable property is True.
editProtected	The column data is not editable.
editEditable	The column data is editable.
Examples

The following example prevents the first column from being edited.

Visual Basic Example

Datatbl1.ColumnSet(0).DataEdit = editProtected

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetDataEdit (editProtected);


DataLen Property

Returns or sets the length, in bytes, of the column data.

Syntax

Visual Basic

Column.DataLen = value

value = Column.DataLen

Visual C++

Column.SetDataLen ( value );

value = Column.GetDataLen ();

The DataLen property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	An integer value specifying the column data length.
Remarks

The data length is only set on properties with variable length, such as strings.

The data length must be set after setting the data type.

Examples

The following example sets the data type of the first column to string and sets the data length to 30.

Visual Basic Example

Datatbl1.ColumnSet(0).DataType = dttString
Datatbl1.ColumnSet(0).DataLen = 30

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetDataType (dttString);
m_dataTbl.GetColumnSet().GetItem(0).SetDataLen (30);


DataType Property

Returns or sets the type of column data.

Syntax

Visual Basic

Column.DataType = value

value = Column.DataType

Visual C++

Column.SetDataType ( value );

value = Column.GetDataType ();

The DataType property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	An integer value specifying the column data type.  (Described in Settings)
Settings

The setting for value are:

Setting	Description
dttShortInt	A short integer.
dttLongInt	A long integer.
dttSingleFloat	A single precision float.
dttDoubleFloat	A double precision float.
dttString	A string
dttDateTime	A date/time value.
dttChar	A character
dttCheckbox	A check box.
dttStdCheckbox	A standard check box.
dttCurrency	A currency value.
dttDate	A file date value.
dttTime	A file time value.
dttUShortInt	A unsigned short integer
dttULongInt	A unsigned long integer
dttBitmap	A bitmap
Examples

The following example sets the data type of the first column to string and sets the data length to 30.

Visual Basic Example

Datatbl1.ColumnSet(0).DataType = dttString
Datatbl1.ColumnSet(0).DataLen = 30

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetDataType (dttString);
m_dataTbl.GetColumnSet().GetItem(0).SetDataLen (30);


DefVal Property

Returns or sets the default value for the column data

Syntax

Visual Basic

Column.DefVal = value

value = Column.DefVal

Visual C++

Column.SetDefVal ( value );

value = Column.GetDefVal ();

The DefVal property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	An string specifying the default value for the column.
Examples

The following example sets the default value of the first column to 1000.

Visual Basic Example

Datatbl1.ColumnSet(0).DefVal = 1000

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetDefVal (1000);


EditAutoHScroll Property

Returns or sets whether the cell contents will automatically scroll horizontally while editing.

Syntax

Visual Basic

Column.EditAutoHScroll = bEnabled

bEnabled = Column.EditAutoHScroll

Visual C++

Column.SetEditAutoHScroll ( bEnabled);

bEnabled = Column.GetEditAutoHScroll ();

The EditAutoHScroll property syntax has these parts:

Part	Description
Column	A DTColumn object.
bEnabled	A boolean value specifying whether the cell contents will automatically scroll horizontally while editing.
Settings

The setting for bEnabled are:

Setting	Description
True	The cell contents will scroll horizontally.
False	The cell contents will not scroll horizontally.
Examples

The following example enables horizontal scrolling while editing for the first column.

Visual Basic Example

Datatbl1.ColumnSet(0).EditAutoHScroll = True

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetEditAutoHScroll (TRUE);


EditAutoVScroll Property

Returns or sets whether the cell contents will automatically scroll vertically while editing.

Syntax

Visual Basic

Column.EditAutoVScroll = bEnabled

bEnabled = Column.EditAutoVScroll

Visual C++

Column.SetEditAutoVScroll ( bEnabled);

bEnabled = Column.GetEditAutoVScroll ();

The EditAutoVScroll property syntax has these parts:

Part	Description
Column	A DTColumn object.
bEnabled	A boolean value specifying whether the cell contents will automatically scroll vertically while editing.
Settings

The setting for bEnabled are:

Setting	Description
True	The cell contents will scroll vertically.
False	The cell contents will not scroll vertically.
Remarks

This property is only used if the EditMultiLine property is set to TRUE.

Examples

The following example enables multi line editing and horizontal scrolling while editing for the first column.

Visual Basic Example

Datatbl1.ColumnSet(0).EditMultiLine = True
Datatbl1.ColumnSet(0).EditAutoVScroll = True

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetEditMultiLine (TRUE);
m_dataTbl.GetColumnSet().GetItem(0).SetEditAutoVScroll (TRUE);


EditLowercase Property

Returns or sets whether characters will be converted to lowercase as they are typed while editing.

Syntax

Visual Basic

Column.EditLowercase = bEnabled

bEnabled = Column.EditLowercase

Visual C++

Column.SetEditLowercase ( bEnabled);

bEnabled = Column.GetEditLowercase ();

The EditLowercase property syntax has these parts:

Part	Description
Column	A DTColumn object.
bEnabled	A boolean value specifying whether characters are converted to lowercase as they are typed while editing.
Settings

The setting for bEnabled are:

Setting	Description
True	The characters will be converted to lowercase.
False	The characters will not be converted to lowercase.
Examples

The following example convert character typed while editing for the first column to lowercase.

Visual Basic Example

Datatbl1.ColumnSet(0).EditLowercase = True

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetEditLowercase (TRUE);


EditMultiLine Property

Returns or sets whether editing is multi line.

Syntax

Visual Basic

Column.EditMultiLine = bEnabled

bEnabled = Column.EditMultiLine

Visual C++

Column.SetEditMultiLine ( bEnabled);

bEnabled = Column.GetEditMultiLine ();

The EditMultiLine property syntax has these parts:

Part	Description
Column	A DTColumn object.
bEnabled	A boolean value specifying whether editing is multi-line.
Settings

The setting for bEnabled are:

Setting	Description
True	Editing will be multi-line.
False	Editing will not be multi-line.
Examples

The following example enables multi line editing.

Visual Basic Example

Datatbl1.ColumnSet(0).EditMultiLine = True

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetEditMultiLine (TRUE);


EditUppercase Property

Returns or sets whether characters will be converted to uppercase as they are typed while editing.

Syntax

Visual Basic

Column.EditUppercase = bEnabled

bEnabled = Column.EditUppercase

Visual C++

Column.SetEditUppercase ( bEnabled);

bEnabled = Column.GetEditUppercase ();

The EditUppercase property syntax has these parts:

Part	Description
Column	A DTColumn object.
bEnabled	A boolean value specifying whether characters are converted to uppercase as they are typed while editing.
Settings

The setting for bEnabled are:

Setting	Description
True	The characters will be converted to uppercase.
False	The characters will not be converted to uppercase.
Examples

The following example convert character typed while editing for the first column to uppercase.

Visual Basic Example

Datatbl1.ColumnSet(0).EditUppercase = True

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetEditUppercase (TRUE);


EditWantReturn Property

Returns or sets whether the return key can be used to move to the next line while editing.

Syntax

Visual Basic

Column.EditWantReturn = bEnabled

bEnabled = Column.EditWantReturn

Visual C++

Column.SetEditWantReturn ( bEnabled);

bEnabled = Column.GetEditWantReturn ();

The EditWantReturn property syntax has these parts:

Part	Description
Column	A DTColumn object.
bEnabled	A boolean value specifying whether the return key can be used to move to the next line while editing.
Settings

The setting for bEnabled are:

Setting	Description
True	The return key can be used.
False	The return key can not be used.
Remarks

If this property is enabled, the return key can not be used to end edit mode.

This property is only used if the EditMultiLine property is set to TRUE.

Examples

The following example enables multi line editing and enables the return key to be used to move to the next line while editing the first column.

Visual Basic Example

Datatbl1.ColumnSet(0).EditMultiLine = True
Datatbl1.ColumnSet(0).EditWantReturn = True

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetEditMultiLine (TRUE);
m_dataTbl.GetColumnSet().GetItem(0).SetEditWantReturn (TRUE);


Extra1 Property

Returns or sets the value of the first extra double word for the column

Syntax

Visual Basic

Column.Extra1 = value

value = Column.Extra1

Visual C++

Column.SetExtra1 ( value );

value = Column.GetExtra1 ();

The Extra1 property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	An long value specifying the value of the column first extra double word.
Remarks

The column extra double words are available to the programmer for any use.

Examples

The following example sets the column first extra double word for the first column

Visual Basic Example

Datatbl1.ColumnSet(0).Extra1 = 1

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetExtra1 (1);


Extra2 Property

Returns or sets the value of the second extra double word for the column

Syntax

Visual Basic

Column.Extra2 = value

value = Column.Extra2

Visual C++

Column.SetExtra2 ( value );

value = Column.GetExtra2 ();

The Extra2 property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	An long value specifying the value of the column second extra double word.
Remarks

The column extra double words are available to the programmer for any use.

Examples

The following example sets the column second extra double word for the first column

Visual Basic Example

Datatbl1.ColumnSet(0).Extra2 = 1

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetExtra2 (1);


Font Property

Returns or sets the font object used when drawing the column text.

Syntax

Visual Basic

Column.Font = fontObj

fontObj = Column.Font

Visual C++

Column.SetFont ( fontObj );

fontObj = Column.GetFont ();

The Font property syntax has these parts:

Part	Description
Column	A DTColumn object.
fontObj	A font object specifying the font used for the column.
Remarks

Initially, no font is assigned to the column.  A font object must be assigned before the font properties can be accessed.

Visual Basic customers assign a font by declaring a new StdFont object and setting the Font property to the new object.

Visual C++ customers assign a font by creating a font dispatch pointer, creating a COleFont property from the font dispatch pointer, and setting the Font property to the new COleFont object.  The Microsoft function OleCreateFontIndirect can be used to create a font dispatch pointer.

Once a font has been assigned to the column, the font properties Bold, Italic, Name, Size, StrikeThrough, Underline, and Weight can be accessed.

Examples

The following example assigns a font to the column and then sets the column font bold property.

Visual Basic Example

Dim X As New StdFont
Set Datatbl1.ColumnSet(0).Font = X
Datatbl1.ColumnSet(0).Font.Bold = True

Visual C++ Example

LPDISPATCH pFontDisp = NULL;
// Create the font dispatch pointer
OleCreateFontIndirect(NULL, IID_IFont,(LPVOID *)&pFontDisp);
// Create the Ole Font
COleFont *NewFont = new COleFont(pFontDisp);
m_dataTbl.GetColumnSet().GetItem(0).SetFont(*NewFont);
m_dataTbl.GetColumnSet().GetItem(0).GetFont().SetBold (TRUE);


ForeColor Property

Returns or sets the foreground color used for the column

Syntax

Visual Basic

Column.ForeColor = color

color = Column.ForeColor

Visual C++

Column.SetForeColor ( color );

color = Column.GetForeColor ();

The ForeColor property syntax has these parts:

Part	Description
Column	A DTColumn object.
color	A long value specifying the column text color.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Examples

The following example sets the text color for the first column.

Visual Basic Example

Datatbl1.ColumnSet(0).ForeColor = RGB(255, 0, 0)

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetForeColor (RGB(255, 0, 0));


Format Property

Returns or sets the column data format string

Syntax

Visual Basic

Column.Format = value

value = Column.Format

Visual C++

Column.SetFormat ( value );

value = Column.GetFormat ();

The Format property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	A string specifying the column format string.
Examples

The following example sets the column formating string for the first column.

Visual Basic Example

Datatbl1.ColumnSet(0).Format = "$0.00"

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetFormat ($0.00);


HeadAlign Property

Returns or sets the alignment of the column heading text.

Syntax

Visual Basic

Column.HeadAlign = value

value = Column.HeadAlign

Visual C++

Column.SetHeadAlign ( value );

value = Column.GetHeadAlign ();

The HeadAlign property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	An integer value specifying the alignment of the heading text.  (Described in Settings)
Settings

The setting for value are:

Setting	Description
horzLeft	Left align the heading text.
horzCenter	Center the heading text.
horzRight	Right align the heading text.
Examples

The following example sets the column heading alignment for the first column.

Visual Basic Example

Datatbl1.ColumnSet(0).HeadAlign = horzCenter

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetHeadAlign (horzCenter);


Heading Property

Returns or sets the column heading text.

Syntax

Visual Basic

Column.Heading = value

value = Column.Heading

Visual C++

Column.SetHeading ( value );

value = Column.GetHeading ();

The Heading property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	A string specifying the column heading.
Examples

The following example sets the column heading of the first column to Last/Name where Last is on the first line and Name is on the second.

Visual Basic Example

Datatbl1.ColumnSet(0).Heading = "Last" + Chr(13) + "Name"

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetHeading (Last\rName);


Hidden Property

Returns or sets whether the column is hidden

Syntax

Visual Basic

Column.Hidden  = bEnabled

bEnabled  = Column.Hidden

Visual C++

Column.SetHidden ( bEnabled  );

bEnabled  = Column.GetHidden ();

The Hidden property syntax has these parts:

Part	Description
Column	A DTColumn object.
bEnabled	An boolean value specifying whether the column is hidden.
Settings

The setting for bEnabled are:

Setting	Description
True	The column is hidden.
False	The column is not hidden
Examples

The following example hides a column.

Visual Basic Example

Dim ColObj As DTColumn
Set ColObj = DataTbl1.ColumnSet(Column)
ColObj.Hidden= True

Visual C++ Example

CDTColumn Col = m_dataTbl.GetColumnSet().GetItem(Column);
Col.SetHidden (TRUE);


List Property

Returns or sets the list of items used for the drop down column

Syntax

Visual Basic

Column.List = value

value = Column.List

Visual C++

Column.SetList ( value );

value = Column.GetList ();

The List property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	An string specifying the list items for a column.
Remarks

The list items are separated by the TAB character.

Example

The following example assigns a list to the first column

Visual Basic Example

DataTbl1.ColumnSet(0).List = "Item0" + Chr(9) + "Item1" + Chr(9) + "Item2

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetList ("Item0\tItem1\tItem2);


Locked Property

Returns or sets whether the column is locked

Syntax

Visual Basic

Column.Locked = bEnabled

bEnabled  = Column.Locked

Visual C++

Column.SetLocked ( bEnabled  );

bEnabled  = Column.GetLocked ();

The Locked property syntax has these parts:

Part	Description
Column	A DTColumn object.
bEnabled	A boolean value specifying whether the column is locked.
Settings

The setting for bEnabled are:

Setting	Description
True	The column is locked.
False	The column is not locked.
Example

The following example locks a column.

Visual Basic Example

Dim ColObj As DTColumn
Set ColObj = DataTbl1.ColumnSet(Column)
ColObj.Locked = True

Visual C++ Example

CDTColumn Col = m_dataTbl.GetColumnSet().GetItem(Column);
Col.SetLocked (TRUE);


Name Property

Returns or sets the symbolic name used to represent the column.  If the column is bound, this property returns or sets the name of the field in the RecordSet which the column is bound to.

Syntax

Visual Basic

Column.Name = value

value = Column.Name

Visual C++

Column.SetName ( value );

value = Column.GetName ();

The Name property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	A string specifying the column symbolic name.  For bound columns, a field in the Recordset.
Examples

The following example sets the symbolic name for the first column.

Visual Basic Example

Datatbl1.ColumnSet(0).Name = StudentID

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetName (StudentID);

Remarks

A DataTable is bound to a database by specifing a Data control in the DataSource property at design time using the Properties window.

A column in the DataTable is bound to a field in the Recordset object by setting the DTColumn objects Bound property to TRUE and Name property to the field name.


Overwrite Property

Returns or sets whether the column data can overwrite adjoining cells.

Syntax

Visual Basic

Column.Overwrite  = bEnabled

bEnabled  = Column.Overwrite

Visual C++

Column.SetOverwrite ( bEnabled  );

bEnabled  = Column.GetOverwrite ();

The Overwrite property syntax has these parts:

Part	Description
Column	A DTColumn object.
bEnabled	A boolean  value specifying whether the data in the column can overwrite adjoining cells.
Settings

The setting for bEnabled are:

Setting	Description
True	The column can overwrite adjoining cells.
False	The column can not overwrite adjoining cells.
Examples

The following example enables the column data to overflow into adjoing cells.

Visual Basic Example

Datatbl1.ColumnSet(0).Overwrite = True

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetOverWrite (TRUE);


Resize Property

Returns or sets whether the display width of the column can be adjusted by the user.

Syntax

Visual Basic

Column.Resize = value

value = Column.Resize

Visual C++

Column.SetResize ( value );

value = Column.GetResize ();

The Resize property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	An integer value specifying whether the column can be resized by the user.
Settings

The setting for value are:

Setting	Description
resizeDefault	The column can only be resized if the DTColumnSet objects AllowResize object is set to TRUE.
resizeFixed	The column can not be resized by the user.
resizeAdjustable	The column can be resized by the user.
Examples

The following example prevents the row label column width from being resized.

Visual Basic Example

Datatbl1.ColumnSet(dtLabelsColumn).Resize = resizeFixed

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(dtLabelsColumn).SetResize (resizeFixed);


SelBackColor Property

Returns or sets the background color of the column when selected.

Syntax

Visual Basic

Column.SelBackColor = color

color = Column.SelBackColor

Visual C++

Column.SetSelBackColor ( color );

color = Column.GetSelBackColor ();

The SelBackColor property syntax has these parts:

Part	Description
Column	A DTColumn object.
color	A long value specifying the column background color for selected items.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Selected items include selected rows, columns, or blocks of cells.

Examples

The following example sets the selected background color for the first column.

Visual Basic Example

Datatbl1.ColumnSet(0).SelBackColor = RGB(255, 0, 0)

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetSelBackColor (RGB(255, 0, 0));


Selected Property

Returns or sets whether the column is selected.

Syntax

Visual Basic

Column.Selected  = bEnabled

bEnabled  = Column.Selected

Visual C++

Column.SetSelected ( bEnabled  );

bEnabled  = Column.GetSelected ();

The Selected property syntax has these parts:

Part	Description
Column	A DTColumn object.
bEnabled	A boolean  value specifying whether the column is selected.
Settings

The setting for bEnabled are:

Setting	Description
True	Select the column.
False	Deselect the column.
Examples

The following example selects the first column.

Visual Basic Example

Datatbl1.ColumnSet(0).Selected= True

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetSelected (TRUE);


SelForeColor Property

Returns or sets the foreground color of the column when selected.

Syntax

Visual Basic

Column.SelForeColor = color

color = Column.SelForeColor

Visual C++

Column.SetSelForeColor ( color );

color = Column.GetSelForeColor ();

The SelForeColor property syntax has these parts:

Part	Description
Column	A DTColumn object.
color	A long value specifying the column text color for selected items.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Selected items include selected rows, columns, or blocks of cells.

Examples

The following example sets the selected text color for the first column.

Visual Basic Example

Datatbl1.ColumnSet(0).SelForeColor = RGB(255, 0, 0)

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).SetSelForeColor (RGB(255, 0, 0));


Value Property

Returns or sets the column data.

Syntax

Visual Basic

Column.Value = value

value = Column.Value

Visual C++

Column.SetValue ( value );

value = Column.GetValue ();

The Value property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	A variant array specifying the column data.
Remarks

The data is specified using a variant containg an array which has an item for each row.

Examples

The following example totals the value in the third column.  It is assumed the third column has a long integer data type.

Visual Basic Example

Dim Info As Variant

Info = Datatbl1.ColumnSet(2).Value
Total =0
For i = 0 To Datatbl1.RowSet.Count -1
Total = Info(i) + Total
Next

Visual C++ Example

long cellval, Total = 0;
CDTData ColumnData = m_dataTbl.GetColumnSet().GetItem(2).GetValue();
for (long i=0; i< m_dataTbl.GetRowSet().GetCount(); i++)
{
ColumnData.GetItem(&cellval, i);
Total+= cellval;
}


Width Property

Returns or sets the display width of the column.

Syntax

Visual Basic

Column.Width = value

value = Column.Width

Visual C++

Column.SetWidth  ( value );

value = Column.GetWidth ();

The Width property syntax has these parts:

Part	Description
Column	A DTColumn object.
value	An integer value specifying the display width of the column.  The width is expressed in the scale units of the DataTables container.
Examples

The following example sets the width for the row labels column.

Visual Basic Example

Datatbl1.ColumnSet(dtLabelsColumn).Width = 1000

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(dtLabelsColumn).SetWidth (25);


The DTColumn Object Methods

The following table list the DTColumn objects methods.

Method	Description
Invalidate Method	Invalidate the area of the column.
Search Method	Search the column for the specified value
Total Method	Total the values in a column.


Invalidate Method

Invalidates the area of the column

Syntax

Visual Basic

Column.Invalidate

Visual C++

Column.Invalidate ( );

The Invalidate method syntax has these parts:

Part	Description
Column	A DTColumn object.
Examples

The following example invalidates the area of the first column.

Visual Basic Example

Datatbl1.ColumnSet(0).Invalidate

Visual C++ Example

m_dataTbl.GetColumnSet().GetItem(0).Invalidate ();


Search Method

Searches the column for a particular value starting after the row specified.  The index of the row where the value is found is returned.

Syntax

Visual Basic

index = Column.Search value, start

Visual C++

index = Column.Search ( value, start );

The Search method syntax has these parts:

Part	Description
Column	A DTColumn object.
value	An variant value specifying the data to search for.
start	A long value specifying the index of the row to start the search after.  Specify -1 to start the search at the beginning of the table..
index	A long value specifying the index of the first row with the specified value.
Examples

The following example searches the sixth column for all occurrences of Smith.

Visual Basic Example

' Search the sixth Column for the first occurrence of Smith
Row = DataTbl1.ColumnSet(5).Search(Smith, 1)

 ' while a row is found
While (Row >= 0)
' process the row

' Search the sixth column for the next occurrence of Smith
Row = DataTbl1.ColumnSet(5).Search(Smith, Row)
Wend

Visual C++ Example

CDTData varSearch= Smith;
long Row = -1;

// retrieve the sixth column DTColumn object
CColumn Col= m_dataTbl.GetColumnSet().GetItem(5);

// while a row is found that contains "Smith"
while ((Row = Col.Search(varSearch,Row)) >=0)
{
// process the row
}


Total Method

Returns the total of the values in the column.

Syntax

Visual Basic

value = Column.Total

Visual C++

value = Column.Total ( );

The Total method syntax has these parts:

Part	Description
Column	A DTColumn object.
value	A variant value specifying the total.
Examples

The following example retrieves the total of the data in the third column.

Visual Basic Example

val = DataTbl1.ColumnSet(2).Total

Visual C++ Example

float total;
CDTData var = m_dataTbl.GetColumnSet().GetItem(2).Total();
// convert the column total to a float
var.Get(&total);


The DTRow Object Properties

The following table list the DTRow objects properties.

Property	Description
BackColor Property	Returns/sets the background color for the row.
Font Property	Returns/sets the font used for the row.
ForeColor Property	Returns/sets the text color for the row.
Height Property	Returns/sets the height of the row.
Label Property	Returns/sets the row label text for the row.
Resize Property	Returns/sets whether the row can be resized.
SelBackColor Property	Returns/sets the selected background color for the row.
Selected Property	Returns/sets whether the row is selected.
SelForeColor Property	Returns/sets the selected text color for the row.
Value Property	Return/sets the cell data for the row.


BackColor Property

Returns or sets the background color of the row.

Syntax

Visual Basic

Row.BackColor = color

color = Row.BackColor

Visual C++

Row.SetBackColor ( color );

color = Row.GetBackColor ();

The BackColor property syntax has these parts:

Part	Description
Row	A DTRow object.
color	A long value specifying the row background color.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Examples

The following example sets the background color for the first row.

Visual Basic Example

Datatbl1.RowSet(0).BackColor = RGB(255, 0, 0)

Visual C++ Example

m_dataTbl.GetRowSet().GetItem(0).SetBackColor (RGB(255, 0, 0));


Font Property

Returns or sets the font object used for the row.

Syntax

Visual Basic

Set Row.Font = FontObj

FontObj = Row.Font

Visual C++

Row.SetFont ( FontObj );

FontObj = Row.GetFont ( );

The Font property syntax has these parts:

Part	Description
Row	A DTRow object.
FontObj	A font object specifying the row font.
Remarks

Initially, no font is assigned to the row.  A font object must be assigned before the font properties can be accessed.

Visual Basic customers assign a font by declaring a new StdFont object and setting the Font property to the new object.

Visual C++ customers assign a font by creating a font dispatch pointer, creating a COleFont property from the font dispatch pointer, and setting the Font property to the new COleFont object.  The Microsoft function OleCreateFontIndirect can be used to create a font dispatch pointer.

Once a font has been assigned to the row, the font properties Bold, Italic, Name, Size, StrikeThrough, Underline, and Weight can be accessed.

Examples

The following example assigns a font to the row and then sets the row font bold property.

Visual Basic Example

Dim X As New StdFont
Set Datatbl1.RowSet(0).Font = X
Datatbl1.RowSet(0).Font.Bold = True

Visual C++ Example

LPDISPATCH pFontDisp = NULL;
// Create a font dispatch pointer
OleCreateFontIndirect(NULL, IID_IFont,(LPVOID *)&pFontDisp);
// Create the Ole Font
COleFont *NewFont = new COleFont(pFontDisp);
m_dataTbl.GetRowSet().GetItem(0).SetFont(*NewFont);
m_dataTbl.GetRowSet().GetItem(0).GetFont().SetBold (TRUE);


ForeColor Property

Returns or sets the foreground color of the row.

Syntax

Visual Basic

Row.ForeColor = color

color = Row.ForeColor

Visual C++

Row.SetForeColor ( color );

color = Row.GetForeColor ();

The ForeColor property syntax has these parts:

Part	Description
Row	A DTRow object.
color	A long value specifying the row text color.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Examples

The following example sets the text color for the first row.

Visual Basic Example

Datatbl1.RowSet(0).ForeColor = RGB(255, 0, 0)

Visual C++ Example

m_dataTbl.GetRowSet().GetItem(0).SetForeColor (RGB(255, 0, 0));


Height Property

Returns or sets the height of  the row.

Syntax

Visual Basic

Row.Height = value

value = Row.Height

Visual C++

Row.SetHeight ( value );

value = Row.GetHeight ();

The Height property syntax has these parts:

Part	Description
Row	A DTRow object.
value	An integer value specifying the row height. The height is specified in the scale units of the DataTable's container.
Examples

The following example sets the height of the first row.

Visual Basic Example

Datatbl1.RowSet(0).Height = 1000

Visual C++ Example

m_dataTbl.GetRowSet().GetItem(0).SetHeight (25);


Label Property

Returns or sets the label text for the row.

Syntax

Visual Basic

Row.Label = value

value = Row.Label

Visual C++

Row.SetLabel ( value );

value = Row.GetLabel ();

The Label property syntax has these parts:

Part	Description
Row	A DTRow object.
value	A string value specifying the row label text.
Examples

The following example sets the row label text for the first row.

Visual Basic Example

Datatbl1.RowSet(0).Label = Active

Visual C++ Example

m_dataTbl.GetRowSet().GetItem(0).SetLabel (Active);


Resize Property

Returns or sets whether the row height can be adjusted by the user.

Syntax

Visual Basic

Row.Resize = value

value = Row.Resize

Visual C++

Row.SetResize ( value );

value = Row.GetResize ();

The Resize property syntax has these parts:

Part	Description
Row	A DTRow object.
value	An integer value specifying whether the row height can be resized by the user.  (Described in Settings.)
Settings

The setting for value are:

Setting	Description
resizeDefault	The row can only be resized if the DTRowSet objects AllowResize object is set to TRUE.
resizeFixed	The row can not be resized by the user.
resizeAdjustable	The row can be resized by the user.
Examples

The following example prevents the column heading row from being resized.

Visual Basic Example

Datatbl1.RowSet(dtHeadingsRow).Resize = resizeFixed

Visual C++ Example

m_dataTbl.GetRowSet().GetItem(dtHeadingsRow).SetResize (resizeFixed);


SelBackColor Property

Returns or sets the background color of the row when selected.

Syntax

Visual Basic

Row.SelBackColor = color

color = Row.SelBackColor

Visual C++

Row.SetSelBackColor ( color );

color = Row.GetSelBackColor ();

The SelBackColor property syntax has these parts:

Part	Description
Row	A DTRow object.
color	A long value specifying the row background color for selected items.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Selected items include selected rows, columns, or blocks of cells.

Examples

The following example sets the selected background color for the first row.

Visual Basic Example

Datatbl1.RowSet(0).SelBackColor = RGB(255, 0, 0)

Visual C++ Example

m_dataTbl.GetRowSet().GetItem(0).SetSelBackColor (RGB(255, 0, 0));


Selected Property

Returns or sets whether the row is selected.

Syntax

Visual Basic

Row.Selected  = bEnabled

bEnabled  = Row.Selected

Visual C++

Row.SetSelected ( bEnabled  );

bEnabled  = Row.GetSelected ();

The Selected property syntax has these parts:

Part	Description
Row	A DTRow object.
bEnabled	A boolean value specifying whether the row is selected.  (Described in Settings.)
Settings

The setting for bEnabled are:

Setting	Description
True	Select the row.
False	Deselect the row.
Examples

The following example selects the first row.

Visual Basic Example

Datatbl1.RowSet(0).Selected = True

Visual C++ Example

m_dataTbl.GetRowSet().GetItem(0).SetSelected (TRUE);


SelForeColor Property

Returns or sets the foreground color of  the row when selected.

Syntax

Visual Basic

Row.SelForeColor = color

color = Row.SelForeColor

Visual C++

Row.SetSelForeColor ( color );

color = Row.GetSelForeColor ();

The SelForeColor property syntax has these parts:

Part	Description
Row	A DTRow object.
color	A long value specifying the row text color for selected items.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Selected items include selected rows, columns, or blocks of cells.

Examples

The following example sets the selected text color for the first row.

Visual Basic Example

Datatbl1.RowSet(0).SelForeColor = RGB(255, 0, 0)

Visual C++ Example

m_dataTbl.GetRowSet().GetItem(0).SetSelForeColor (RGB(255, 0, 0));


Value Property

Returns or sets the value of the row data.

Syntax

Visual Basic

Row.Value = value

value = Row.Value

Visual C++

Row.SetValue ( value );

value = Row.GetValue ();

The Value property syntax has these parts:

Part	Description
Row	A DTRow object.
value	An array of variants specifying the new row data.
Remarks

The row data is specified by a variant containing an array where there is an item for each column.

Examples

The following example totals the value in the last row.  It is assumed the table contains only columns with a long integer data type.

Visual Basic Example

Dim Info As Variant

Info = Datatbl1.RowSet(dtLast).Value
Total =0
For i = 0 To Datatbl1.ColumnSet.Count -1
Total = Info(i) + Total
Next

Visual C++ Example

long cellval, Total = 0;
CDTData RowData = m_dataTbl.GetRowSet().GetItem(dtLast).GetValue();
for (long i=0; i< m_dataTbl.GetColumnSet().GetCount(); i++)
{
RowData.GetItem(&cellval, i);
Total+= cellval;
}


The DTRow Object Methods

The following table list the DTRow objects methods.

Method	Description
Invalidate Method	Invalidate the area of the row.


Invalidate Method

Invalidate the area of the row.

Syntax

Visual Basic

Row.Invalidate

Visual C++

Row.Invalidate

The Invalidate method syntax has these parts:

Part	Description
Row	A DTRow object.
Examples

The following example invalidates the area of the top most visible row.

Visual Basic Example

Row = Datatbl1.RowSet.FirstVisible
Datatbl1.RowSet(Row).Invalidate

Visual C++ Example

long Row = m_dataTbl.GetRowSet().GetFirstVisible();
m_dataTbl.GetRowSet().GetItem(Row).Invalidate ();


The DTCell Object Properties

The following table list the DTCell objects properties.

Property	Description
BackColor Property	Returns/sets the background color for the cell.
Font Property	Returns/sets the font used for thecell.
ForeColor Property	Returns/sets the text color for the cell.
NullFlag Property	Returns/sets whether the cell has a null value.
SelBackColor Property	Returns/sets the selected background color for the cell.
Selected Property	Returns whether the cell is in the selected block.
SelForeColor Property	Returns/sets the selected text color for the cell.
Value Property	Return/sets the cell data.


BackColor Property

Returns or sets the background color of the cell.

Syntax

Visual Basic

Cell.BackColor = color

color = Cell.BackColor

Visual C++

Cell.SetBackColor ( color );

color = Cell.GetBackColor ();

The BackColor property syntax has these parts:

Part	Description
Cell	A DTCell object.
color	A long value specifying the cell background color.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Examples

The following example sets the background color for the cell located at the first row, first column to red.

Visual Basic Example

Datatbl1.CellSet(0,0).BackColor = RGB(255, 0, 0);

Visual C++ Example

m_dataTbl.GetCellSet().GetItem(0,0).SetBackColor (RGB(255, 0, 0));


Font Property

Returns or sets the font object used for the cell.

Syntax

Visual Basic

Set Cell.Font = FontObj

FontObj = Cell.Font

Visual C++

Cell.SetFont ( FontObj );

FontObj = Cell.GetFont ( );

The Font property syntax has these parts:

Part	Description
Cell	A DTCell object.
FontObj	A font object specifying the cell font.
Remarks

Initially, no font is assigned to the cell.  A font object must be assigned before the font properties can be accessed.

Visual Basic customers assign a font by declaring a new StdFont object and setting the Font property to the new object.

Visual C++ customers assign a font by creating a font dispatch pointer, creating a COleFont property from the font dispatch pointer, and setting the Font property to the new COleFont object.  The Microsoft function OleCreateFontIndirect can be used to create a font dispatch pointer.

Once a font has been assigned to the cell, the font properties Bold, Italic, Name, Size, StrikeThrough, Underline, and Weight can be accessed.

Examples

The following example assigns a font to the cell then sets the cell font bold property.

Visual Basic Example

Dim X As New StdFont
Set Datatbl1.CellSet(0, 0).Font = X
Datatbl1.CellSet(0, 0).Font.Bold = True

Visual C++ Example

LPDISPATCH pFontDisp = NULL;
// Create a font dispatch pointer
OleCreateFontIndirect(NULL, IID_IFont,(LPVOID *)&pFontDisp);
// Create the Ole Font
COleFont *NewFont = new COleFont(pFontDisp);
m_dataTbl.GetCellSet().GetItem(0, 0).SetFont(*NewFont);
m_dataTbl.GetCellSet().GetItem(0, 0).GetFont().SetBold (TRUE);


ForeColor Property

Returns or sets the foreground color of the cell.

Syntax

Visual Basic

Cell.ForeColor = color

color = Cell.ForeColor

Visual C++

Cell.SetForeColor ( color );

color = Cell.GetForeColor ();

The ForeColor property syntax has these parts:

Part	Description
Cell	A DTCell object.
color	A long value specifying the cell text color.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Examples

The following example sets the text color for the cell located at the first row, first column to red.

Visual Basic Example

Datatbl1.CellSet(0,0).ForeColor = RGB(255, 0, 0);

Visual C++ Example

m_dataTbl.GetCellSet().GetItem(0,0).SetForeColor (RGB(255, 0, 0));


NullFlag Property

Returns or sets whether the cell has a null value.

Syntax

Visual Basic

Cell.NullFlag  = bEnabled

bEnabled  = Cell.NullFlag

Visual C++

Cell.SetNullFlag ( bEnabled );

bEnabled  = Cell.GetNullFlag ();

The NullFlag property syntax has these parts:

Part	Description
Cell	A DTCell object.
bEnabled	A boolean value specifying if the cell is flagged as having a null value.  (Described in Settings.)
Settings

The setting for bEnabled are:

Setting	Description
True	The cell has a null value.
False	The cell does not have a null value.
Examples

The following example determines if the cell located at the first row, first column has a null value

Visual Basic Example

If (Datatbl1.CellSet(0,0).NullFlag) Then
 Process null cell
End If

Visual C++ Example

if (m_dataTbl.GetCellSet().GetItem(0,0).GetNullFlag ())
{
// process null cell
}


SelBackColor Property

Returns or sets the background color of the cell when selected.

Syntax

Visual Basic

Cell.SelBackColor = color

color = Cell.SelBackColor

Visual C++

Cell.SetSelBackColor ( color );

color = Cell.GetSelBackColor ();

The SelBackColor property syntax has these parts:

Part	Description
Cell	A DTCell object.
color	A long value specifying the cell background color for selected items.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Selected items include selected rows, columns, or blocks of cells.

Examples

The following example sets the selected background color for the cell located at the first row, first column to red.

Visual Basic Example

Datatbl1.CellSet(0,0).SelBackColor = RGB(255, 0, 0);

Visual C++ Example

m_dataTbl.GetCellSet().GetItem(0,0).SetSelBackColor (RGB(255, 0, 0));


Selected Property

Returns whether the cell is in the selected block.

Syntax

Visual Basic

bSelected = Cell.Selected

Visual C++

bSelected = Cell.GetSelected ();

The Selected property syntax has these parts:

Part	Description
Cell	A DTCell object.
bSelected	A boolean value specifying whether the cell is selected.  (Described in Settings.)
Settings

The setting for bEnabled are:

Setting	Description
True	The cell is selected.
False	The cell is not selected.
Remarks

This property is read only.

Examples

The following example determines if the cell located at the first row, first column is selected.

Visual Basic Example

If (Datatbl1.CellSet(0,0).Selected ) Then
 Process selected cell
End If

Visual C++ Example

if (m_dataTbl.GetCellSet().GetItem(0,0).GetSelected ())
{
    // process selected cell
}


SelForeColor Property

Returns or sets the foreground color of the cell when selected

Syntax

Visual Basic

Cell.SelForeColor = color

color = Cell.SelForeColor

Visual C++

Cell.SetSelForeColor ( color );

color = Cell.GetSelForeColor ();

The SelForeColor property syntax has these parts:

Part	Description
Cell	A DTCell object.
color	A long value specifying the cell text color for selected items.
Remarks

color can be a RGB color, a system color constant, or the constant dtDefaultColor.  The constant dtDefaultColor is used to specify no color assignment.

Selected items include selected rows, columns, or blocks of cells.

Examples

The following example sets the selected text color for the cell located at the first row, first column to red.

Visual Basic Example

Datatbl1.CellSet(0,0).SelForeColor = RGB(255, 0, 0);

Visual C++ Example

m_dataTbl.GetCellSet().GetItem(0,0).SetSelForeColor (RGB(255, 0, 0));


Value Property

Returns or sets the data for the cell.

Syntax

Visual Basic

Cell.Value = value

value = Cell.Value

Visual C++

Cell.SetValue ( value );

value = Cell.GetValue ();

The Value property syntax has these parts:

Part	Description
Cell	A DTCell object.
value	A variant value specifying the cell data
Examples

The following example sets the value of the cell located at the first row, first column to 1000.

Visual Basic Example

Datatbl1.CellSet(0,0).Value = 1000;

Visual C++ Example

CDTData Val = 1000;
m_dataTbl.GetCellSet().GetItem(0,0).SetValue (Val);


The DTCell Object Methods

The following table list the DTCell objects methods.

Method	Description
GetRect Method	Retrieves the coordinates for the bounding rectangle of the cell.
Invalidate Method	Invalidates the area of the cell
MakeVisible Method	Scrolls the table horizontally and vertically so that the cell becomes visible.


GetRect Method

Retrieves the coordinates for the bounding rectangle of the cell.

Syntax

Visual Basic

bSuccess = Cell.GetRect ( Pane, Left, Top, Right, Bottom )

Visual C++

bSuccess = Cell.GetRect ( Pane, Left, Top, Right, Bottom);

The GetRect method syntax has these parts:

Part	Description
Cell	A DTCell object.
Pane	An integer value specifying which pane to retrieve the bounding rectangle for. (Described in Settings.)
Left	A floating point value specifying the distance from the left edge of the cell and the left edge of the DataTable.
Top	A floating point value specifying the distance from the top edge of the cell and the top edge of the DataTable.
Right	A floating point value specifying the distance from the right edge of the cell and the left edge of the DataTable.
Bottom	A floating point value specifying the distance from the bottom edge of the cell and the top edge of the DataTable.
bSuccess	A boolean value specifying if the bounding rectangle can be determined. (Described in Settings.)
Settings

The setting for bSuccess are:

Setting	Description
True	The bounding rectangle was determined.
False	The bounding rectangle can not be determined.

The settings for Pane are:

Constant	Meaning
paneLabelTop	Row label column, Top Pane
paneLockedTop	Locked column pane, Top Pane
paneLeftTop	Left Pane, Top Pane
paneRightTop	Right Pane, Top Pane
paneLabelBottom	Row label column, Bottom Pane
paneLockedBottom	Locked column pane, Bottom Pane
paneLeftBottom	Left Pane, Bottom Pane
paneRightBottom	Right Pane, Bottom Pane
Remarks

The Left, Top, Right, and Bottom parameters are expressed in terms of the containers coordinate system.

This method is useful when implementing owner drawn cells.

Examples

The following example retrieves the bounding rectangle for the cell located at Row, Column.

Visual Basic Example

If (Datatbl1.CellSet(Row, Column).GetRect (Pane, left, top, right, bottom)) Then
 process
End If

Visual C++ Example

if (m_dt.GetCellSet().GetItem(Row, Column).GetRect (Pane, &left, &top,
&right, &bottom))
{
// process
}


Invalidate Method

Invalidate the area of the cell.

Syntax

Visual Basic

Cell.Invalidate

Visual C++

Cell.Invalidate ( );

The Invalidate method syntax has these parts:

Part	Description
Cell	A DTCell object.
Examples

The following example invalidates the area of the cell located at the first row, first column.

Visual Basic Example

Datatbl1.CellSet(0,0).Invalidate

Visual C++ Example

m_dataTbl.GetCellSet().GetItem(0,0).Invalidate ();


MakeVisible Method

Scrolls the table horizontally and vertically so that the cell becomes visible.

Syntax

Visual Basic

Cell.MakeVisible

Visual C++

Cell.MakeVisible ( );

The MakeVisible method syntax has these parts:

Part	Description
Cell	A DTCell object.
Examples

The following example makes the cell located at the first row, first column visible.

Visual Basic Example

Datatbl1.CellSet(0,0).MakeVisible

Visual C++ Example

m_dataTbl.GetCellSet().GetItem(0,0).MakeVisible ();


Event Category Reference

The following section groups the DataTable events by category.

User Selection Events

The following events are fired when a user selection has changed.

Event	Fired When
BeforeBlockSel	A block is about to be selected.
BlockSel	A block is selected.
BlockUnSel	A block is unselected.
BeforeRowSel	A row is about to be selected.
RowSel	A row is selected.
RowUnSel	A row is unselected.
BeforeColSel	A column is about to be selected.
ColSel	A column is selected.
ColUnSel	A column is unselected.
Clipboard Events

The following events are fired when data is transferred to and from the clipboard.

Event	Fired When
BeforeCut	A cut is about to be performed.
BeforeCopy	A copy is about to be performed.
BeforePaste	A paste is about to be performed.
Row Events

The following events are triggered when a row has been altered.

Event	Fired When
BeforeInsert	A row is about to be inserted.
InsertedRow	A row has been inserted.
BeforeDeleteRow	A row is about to be deleted.
DeletedRow	A row has been deleted.
RowSize	A row has been resized.
Column Events

The following events are triggered when

Event	Fired When
ColAdded	A column has been inserted.
ColDeleted	A column has been deleted.
ColMoved	A column has been moved.
ColSize	A column has been resized.
ColNameChange	A columns symbolic name has changed.
Current Cell Events

The following events are triggered when the current cell has changed.

Event	Fired When
PosChange	The current cell has changed
RowChange	The current cells row index has changed
ColChange	The current cells column index has changed
Mouse Events

The following events are triggered by the mouse

Event	Fired When
LfClick	The left mouse button has been clicked.
RtClick	The right mouse button has been clicked.
LfDblClick	The left mouse button has been double clicked.
RtDblClick	The right mouse button has been double clicked.
MouseUp	The user has released a mouse button.
MouseDown	The user has pressed a mouse button.
MouseMove	The user has moved the mouse over the DataTable.
Edit Events

The following events are fired when the DataTable is edited.

Event	Fired When
BeforeBeginEdit	Edit mode is about to begin.
BeginEdit	Edit mode has begun.
CellFull	The user has entered as much data as will fit in a cell.
BeforeAbortEdit	Edit mode is about to be aborted.
AbortEdit	Edit mode has been aborted.
BeforeEndEdit	Edit mode is about to be ended.
Update	Edit mode is ending, the cells data is about to updated with the new value.
Change	Edit mode has ended, the cells data is updated.
ComboCloseUp	The drop down list has been closed up.
ComboDropDn	The drop down list has been dropped down.
Keystroke Events

The following events are fired by the

Event	Fired When
KeyUp	A key is relased.
KeyDown	A key is pressed.
KeyPress	An ANSI key is pressed and released.
EditKeyUp	A key is released while editing.
EditKeyDown	A key is pressed while editing.
EditKeyPress	An ANSI key is pressed and released while editing.
Other Events

Event	Fired When
PaintCell	A cell is about to be painted.
Create	The DataTable is created.
Destroy	The DataTable is destroyed.
DropDown	The DataTable is dropped down.
HScroll	The DataTable has scrolled horizontally.
VScroll	The DataTable has scrolled vertically.
Error	An error has occurred.


Event Alphabetical Reference

The following section provides an alphabetical reference to the DataTable events.

Event	Fired When
AbortEdit	Edit mode has been aborted.
BeforeAbortEdit	Edit mode is about to be aborted.
BeforeBeginEdit	Edit mode is about to begin.
BeforeBlockSel	A block is about to be selected.
BeforeColSel	A column is about to be selected.
BeforeCopy	A copy is about to be performed.
BeforeCut	A cut is about to be performed.
BeforeDeleteRow	A row is about to be deleted.
BeginEdit	Edit mode has begun.
BeforeEndEdit	Edit mode is about to be ended.
BeforeInsert	A row is about to be inserted.
BeforePaste	A paste is about to be performed.
BeforeRowSel	A row is about to be selected.
BlockSel	A block is selected.
BlockUnSel	A block is unselected.
CellFull	The user has entered as much data as will fit in a cell.
Change	Edit mode has ended, the cells data is updated.
ColAdded	A column has been inserted.
ColChange	The current cells column index has changed
ColDeleted	A column has been deleted.
ColMoved	A column has been moved.
ColNameChange	A columns symbolic name has changed.
ColSel	A column is selected.
ColSize	A column has been resized.
ColUnSel	A column is unselected.
ComboCloseUp	The drop down list has been closed up.
ComboDropDn	The drop down list has been dropped down.
Create	The DataTable is created.
DeletedRow	A row has been deleted.
Destroy	The DataTable is destroyed.
DropDown	The DataTable is dropped down.
EditKeyUp	A key is released while editing.
EditKeyDown	A key is pressed while editing.
EditKeyPress	An ANSI key is pressed and released while editing.
Error	An error has occurred.
HScroll	The DataTable has scrolled horizontally.
InsertedRow	A row has been inserted.
KeyDown	A key is pressed.
KeyPress	An ANSI key is pressed and released.
KeyUp	A key is relased.
LfClick	The left mouse button has been clicked.
LfDblClick	The left mouse button has been double clicked.
MouseDown	The user has pressed a mouse button.
MouseMove	The user has moved the mouse over the DataTable.
MouseUp	The user has released a mouse button.
PaintCell	A cell is about to be painted.
PosChange	The current cell has changed
RowChange	The current cells row index has changed
RowSel	A row is selected.
RowSize	A row has been resized.
RowUnSel	A row is unselected.
RtClick	The right mouse button has been clicked.
RtDblClick	The right mouse button has been double clicked.
Update	Edit mode is ending, the cells data is about to updated with the new value.
VScroll	The DataTable has scrolled vertically.


AbortEdit Event

Occurs when editing of the current cell has been aborted.

Syntax

Visual Basic

Private Sub Datatbl1_AbortEdit(ByVal Row As Long,
            ByVal Column As Long)

Visual C++

void OnAbortEditDatatblctrl1(long Row, long Column);

The AbortEdit event syntax has these parts:

Part	Description
Row	The column index of the cell that was being edited.
Column	The row index of the cell that was being edited.


BeforeAbortEdit Event

Occurs before editing is aborted.

Syntax

Visual Basic

Private Sub Datatbl1_BeforeAbortEdit(ByVal Row As Long,
        ByVal Column As Long, Status As Long)

Visual C++

void OnBeforeAbortEditDatatblctrl1(long Row, long Column,
        long FAR* Status);

The BeforeAbortEdit event syntax has these parts:

Part	Description
Row	The row index of the cell that was being edited.
Column	The column index of the cell that was being edited.
Status	The event return code.
Remarks

If the Status argument is set to non zero while processing this event, editing is not aborted.


BeforeBeginEdit Event

Occurs before editing is begun.

Syntax

Visual Basic

Private Sub Datatbl1_BeforeBeginEdit(ByVal Row As Long,
            ByVal Column As Long, Status As Long)

Visual C++

void OnBeforeBeginEditDatatblctrl1(long Row, long Column,
             long FAR* Status);

The BeforeBeginEdit event syntax has these parts:

Part	Description
Row	The row index of the cell to be edited.
Column	The column index of the cell to be edited.
Status	The event return code.
Remarks

If the Status argument is set to non zero while processing this event, editing is not begun.


BeforeBlockSel Event

Occurs before a block of cells is selected.

Syntax

Visual Basic

Private Sub Datatbl1_BeforeBlockSel(ByVal TopRow As Long,
            ByVal LeftColumn As Long, ByVal BottomRow As Long,
            ByVal RightColumn As Long, Status As Long)

Visual C++

void OnBeforeBlockSelDatatblctrl1(long TopRow, long LeftColumn,
             long BottomRow, long RightColumn, long FAR* Status);

The BeforeBlockSel event syntax has these parts:

Part	Description
TopRow	The row index of the top row of the block.
LeftColumn	The column index of the left column of the block.
BottomRow	The row index of the bottom row of the block.
RightColumn	The column index of the right column of the block.
Status	The event return code.
Remarks

If the Status argument is set to non zero while processing this event, the block is not selected.


BeforeColSel Event

Occurs before a column is selected.

Syntax

Visual Basic

Private Sub Datatbl1_BeforeColSel(ByVal Column As Long,
             Status As Long)

Visual C++

void OnBeforeColSelDatatblctrl1(long Column, long FAR* Status);

The BeforeColSel event syntax has these parts:

Part	Description
Column	The column index of the column being selected.
Status	The event return code.
Remarks

If the Status argument is set to non zero while processing this event, the column is not selected.


BeforeCopy Event

 Occurs before the contents of the selected items is copied to the clipboard.

Syntax

Visual Basic

Private Sub Datatbl1_BeforeCopy(Status As Long)

Visual C++

void OnBeforeCopyDatatblctrl1(long FAR* Status);

The BeforeCopy event syntax has these parts:

Part	Description
Status	The event return code.
Remarks

If the Status argument is set to non zero while processing this event, the selection is not copied to the clipboard.


BeforeCut Event

 Occurs before the contents of the selected items is copied to the clipboard and the cells cleared.

Syntax

Visual Basic

Private Sub Datatbl1_BeforeCut(Status As Long)

Visual C++

void OnBeforeCutDatatblctrl1(long FAR* Status);

The BeforeCut event syntax has these parts:

Part	Description
Status	The event return code.
Parameters

Status is the event return code

Remarks

If the Status argument is set to non zero while processing this event, the contents of the selected items is not copied to the clipboard and then cleared.


BeforeDeleteRow Event

 Occurs before a row is deleted.

Syntax

Visual Basic

Private Sub Datatbl1_BeforeDeleteRow(ByVal Row As Long,
                Status As Long)

Visual C++

void OnBeforeDeleteRowDatatblctrl1(long Row, long FAR* Status);

The BeforeDeleteRow event syntax has these parts:

Part	Description
Row	The row index of the row to be deleted.
Status	The event return code.
Remarks

If the Status argument is set to non zero while processing this event, the row is not deleted.


BeforeEndEdit Event

Occurs before editing is ended.

Syntax

Visual Basic

Private Sub Datatbl1_BeforeEndEdit(ByVal Row As Long,
            ByVal Column As Long, Status As Long)

Visual C++

void OnBeforeEndEditDatatblctrl1(long Row, long Column,
            long FAR* Status);

The BeforeEndEdit event syntax has these parts:

Part	Description
Row	The row index of the cell being edited.
Column	The column index of the cell being edited.
Status	The event return code.
Remarks

If the Status argument is set to non zero while processing this event, editing is not ended.


BeforeInsertRow Event

Occurs before a row is inserted.

Syntax

Visual Basic

Private Sub Datatbl1_BeforeInsertRow(ByVal Row As Long,
            Status As Long)

Visual C++

void OnBeforeInsertRowDatatblctrl1(long Row, long FAR* Status);

The BeforeRowInsertRow event syntax has these parts:

Part	Description
Row	The index of the row where the new row will be inserted prior to.
Status	The event return code.
Remarks

If the Status argument is set to non zero while processing this event, the row is not inserted.


BeforePaste Event

 Occurs before the contents of the clipboard is pasted to the DataTable.

Syntax

Visual Basic

Private Sub Datatbl1_BeforePaste(Status As Long)

Visual C++

void OnBeforePasteDatatblctrl1(long FAR* Status);

The BeforePaste event syntax has these parts:

Part	Description
Status	The event return code.
Remarks

If the Status argument is set to non zero while processing this event, the contents of the clipboard is not copied to the DataTable.


BeforeRowSel Event

Occurs before a row is selected.

Syntax

Visual Basic

Private Sub Datatbl1_BeforeRowSel(ByVal Row As Long,
           Status As Long)

Visual C++

void OnBeforeRowSelDatatblctrl1(long Row, long FAR* Status);

The BeforeRowSel event syntax has these parts:

Part	Description
Row	The row index of the row being selected.
Status	The event return code.
Remarks

If the Status argument is set to non zero while processing this event, the row is not selected.


BeginEdit Event

Occurs when editing has begun on the current cell

Syntax

Visual Basic

Private Sub Datatbl1_BeginEdit(ByVal Row As Long,
            ByVal Column As Long)

Visual C++

void OnBeginEditDatatblctrl1(long Row, long Column);

The BeginEdit event syntax has these parts:

Part	Description
Row	The row index of the cell being edited.
Column	The column index of the cell being edited.


BlockSel Event

Occurs when a  block of cells has been selected.

Syntax

Visual Basic

Private Sub Datatbl1_BlockSel(ByVal TopRow As Long,
            ByVal LeftCol As Long, ByVal BottomRow As Long,
            ByVal RightCol As Long)

Visual C++

void OnBlockSelDatatblctrl1(long TopRow, long LeftCol,
        long BottomRow, long RightCol);

The BlockSel event syntax has these parts:

Part	Description
TopRow	The row index of the top row of the block.
LeftColumn	The column index of the left column of the block.
BottomRow	The row index of the bottom row of the block.
RightColumn	The column index of the right column of the block.
Status	The event return code.


BlockUnSel Event

Occurs when a block of cells has been deselected.

Syntax

Visual Basic

Private Sub Datatbl1_BlockUnSel(ByVal TopRow As Long,
            ByVal LeftCol As Long, ByVal BottomRow As Long,
            ByVal RightCol As Long)

Visual C++

void OnBlockUnSelDatatblctrl1(long TopRow, long LeftCol,
        long BottomRow, long RightCol);

The BlockUnSel event syntax has these parts:

Part	Description
TopRow	The row index of the top row of the block.
LeftColumn	The column index of the left column of the block.
BottomRow	The row index of the bottom row of the block.
RightColumn	The column index of the right column of the block.
Status	The event return code.


CellFull Event

 Occurs when the user has entered as much data as will fit in the current cell

Syntax

Visual Basic

Private Sub Datatbl1_CellFull(ByVal Row As Long,
            ByVal Column As Long)

Visual C++

void OnCellFullDatatblctrl1(long Row, long Column);

The CellFull event syntax has these parts:

Part	Description
Row	The row index of the cell being edited.
Column	The column index of the cell being edited.


Change Event

 Occurs when editing mode has ended and the cell contents have been updated with the new value.

Syntax

Visual Basic

Private Sub Datatbl1_Change(ByVal Row As Long,
            ByVal Column As Long)

Visual C++

void OnChangeDatatblctrl1(long Row, long Column);

The Change event syntax has these parts:

Part	Description
Row	The row index of the cell being changed.
Column	The column index of the cell being changed.


ColAdded Event

 Occurs when a column has been added

Syntax

Visual Basic

Private Sub Datatbl1_ColAdded(ByVal Column As Long)

Visual C++

void OnColAddedDatatblctrl1(long Column);

The ColAdded event syntax has these parts:

Part	Description
Column	The column index of the new column.


ColChange Event

 Occurs when the column index of the current cell has changed.

Syntax

Visual Basic

Private Sub Datatbl1_ColChange(ByVal Column As Long)

Visual C++

void OnColChangeDatatblctrl1(long Column);

The ColAdded event syntax has these parts:

Part	Description
Column	The column index of the old current column.
Remarks

The column index of the new current cell can be determined using the DTCurCell objects Column property.


ColDeleted Event

 Occurs when a column has been deleted.

Syntax

Visual Basic

Private Sub Datatbl1_ColDeleted(ByVal Column As Long)

Visual C++

void OnColDeletedDatatblctrl1(long Column);

The ColDeleted event syntax has these parts:

Part	Description
Column	The column index of the deleted column.


ColMoved Event

 Occurs when a column has been moved

Syntax

Visual Basic

Private Sub Datatbl1_ColMoved(ByVal Column As Long)

Visual C++

void OnColMovedDatatblctrl1(long Column);

The ColMoved event syntax has these parts:

Part	Description
Column	The column index of the moved column.


ColNameChanged Event

 Occurs when the symbolic name of a column has been changed.

Syntax

Visual Basic

Private Sub Datatbl1_ColNameChanged(ByVal Column As Long)

Visual C++

void OnColNameChangedDatatblctrl1(long Column);

The ColNameChanged event syntax has these parts:

Part	Description
Column	The column index of the changed column.


ColSel Event

 Occurs when a column has been selected.

Syntax

Visual Basic

Private Sub Datatbl1_ColSel(ByVal Column As Long)

Visual C++

void OnColSelDatatblctrl1(long Column);

The ColSel event syntax has these parts:

Part	Description
Column	The column index of the selected column.


ColSize Event

 Occurs when a the size of a column has been changed.

Syntax

Visual Basic

Private Sub Datatbl1_ColSize(ByVal Column As Long)

Visual C++

void OnColSizeDatatblctrl1(long Column);

The ColSize event syntax has these parts:

Part	Description
Column	The column index of the changed column.


ColUnSel Event

 Occurs when a column has been deselected.

Syntax

Visual Basic

Private Sub Datatbl1_ColUnSel(ByVal Column As Long)

Visual C++

void OnColUnSelDatatblctrl1(long Column);

The ColUnSel event syntax has these parts:

Part	Description
Column	The column index of the deselected column.


ComboCloseUp Event

 Occurs when the combo box displayed while editing has closed up.

Syntax

Visual Basic

Private Sub Datatbl1_ComboCloseUp(ByVal Row As Long,
            ByVal Column As Long)

Visual C++

void OnComboCloseUpDatatblctrl1(long Row, long Column);

The ComboCloseUp event syntax has these parts:

Part	Description
Row	The row index of the cell being edited.
Column	The column index of the cell being edited..


ComboDropDn Event

 Occurs when the combo box displayed while editing has dropped down.

Syntax

Visual Basic

Private Sub Datatbl1_ComboDropDn(ByVal Row As Long,
            ByVal Column As Long)

Visual C++

void OnComboDropDnDatatblctrl1(long Row, long Column);

The ComboDropDn event syntax has these parts:

Part	Description
Row	The row index of the cell being edited.
Column	The column index of the cell being edited..


Create Event

Occurs when the DataTable has been created.

Syntax

Visual Basic

Private Sub Datatbl1_Create()

Visual C++

void OnCreateDatatblctrl1();


DeletedRow Event

Occurs when a row has been deleted.

Syntax

Visual Basic

Private Sub Datatbl1_DeletedRow(ByVal Row As Long)

Visual C++

void OnDeletedRowDatatblctrl1(long Row);

The DeletedRow event syntax has these parts:

Part	Description
Row	The row index of the deleted row.


Destroy Event

The DataTable is about to be destroyed.

Syntax

Visual Basic

Private Sub Datatbl1_Destroy()

Visual C++

void OnDestroyDatatblctrl1();


DropDn Event

Occurs when the DataTable has been dropped down or closed up.

Syntax

Visual Basic

Private Sub Datatbl1_DropDn()

Visual C++

void OnDropDnDatatblctrl1();


EditKeyDown  Event

Occurs when the user presses a key and the DataTable is currently being edited.

Syntax

Visual Basic

Private Sub Datatbl1_EditKeyDown(keycode As Integer,
            shift As Integer)

Visual C++

void OnEditKeyDownDatatblctrl1(short FAR* KeyCode, short Shift)

The EditKeyDown event syntax has these parts:

Part	Description
KeyCode	An integer that represents the virtual key code of the pressed key. (Described in Settings)
shift	A bit field that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. (Described in Settings)
Settings

The keycode argument can be changed to simulate a different key being pressed.  Changing keycode to 0 cancels the key press.

The shift argument can have some, all, or none of the following bit masks set:

Constant	Bit	Value	Description
vbShiftMask	0	1	SHIFT key bit mask.
vbCTRLMask	1	2	CTRL key bit mask.
VbALTMask	2	4	ALT key bit mask
To test whether the SHIFT, CTRL or ALT key is pressed, perform an And operation between the shift argument and the bit mask and check if the results is equal to the bit mask.  The following example tests whether the SHIFT key is pressed.

Visual Basic

ShiftIsPressed = (shift And vbShiftMask) = vbShiftMask

Visual C++

ShiftIsPressed = (Shift & vbShiftMask) == vbShiftMask

Remarks

The EditKeyDown event is useful when you need to determine when function or navigational keys are pressed, since these keys do not fire a EditKeyPress event.


EditKeyPress Event

Occurs when the user presses and releases an ANSI key and the DataTable is being edited.

Syntax

Visual Basic

Private Sub Datatbl1_EditKeyPress(keyascii As Integer)

Visual C++

void OnEditKeyPressDatatblctrl1(short FAR* KeyAscii)

The EditKeyPress event syntax has these parts:

Part	Description
keyascii	An integer that represents the ANSI keycode.
Remarks

The keyascii parameter can be changed to simulate a different character.

Changing keyascii to 0 cancels the keystroke.

Visual basic users can convert the keyascii argument into a character by using the expression: char = Chr(keyascii). The character can later be converted back to an ANSI number using the expression:  keyascii = Asc(char).

Examples

The following example does not allow numbers to be entered and converts lowercase letters to uppercase.

Private Sub Datatbl1_EditKeyPress(KeyAscii As Integer)
Char = Chr(KeyAscii)
If (Char >= "0" And Char <= "9") Then
    '  Don't allow numbers
    KeyAscii = 0
Else
    ' convert to uppercase
    KeyAscii = Asc(UCase(Char))
End If
End Private Sub


EditKeyUp Event

Occurs when the user releases a key and the DataTable is currently being edited.

Syntax

Visual Basic

Private Sub Datatbl1_EditKeyUp(keycode As Integer, shift As Integer)

Visual C++

void OnEditKeyUpDatatblctrl1(short FAR* KeyCode, short Shift)

The EditKeyUp event syntax has these parts:

Part	Description
KeyCode	An integer representing the virtual key code of the released key. (Described in Settings)
shift	A bit field that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. (Described in Settings)
Settings

The keycode argument can be changed to simulate a different key being released.  Changing keycode to 0 cancels the key release.

The shift argument can have some, all, or none of the following bit masks set:

Constant	Bit	Value	Description
vbShiftMask	0	1	SHIFT key bit mask.
vbCTRLMask	1	2	CTRL key bit mask.
VbALTMask	2	4	ALT key bit mask
To test whether the SHIFT, CTRL or ALT key is pressed, perform an And operation between the shift argument and the bit mask and check if the results is equal to the bit mask.  The following example tests whether the SHIFT key is pressed.

Visual Basic

ShiftIsPressed = (shift And vbShiftMask) = vbShiftMask

Visual C++

ShiftIsPressed = (Shift & vbShiftMask) == vbShiftMask


Error Event

Fired when an error occurs within the DataTable outside of the scope of a method call or property access.

Syntax

Visual Basic

Private Sub Datatbl1_Error(Number As Integer, Description As
              String, Scode As Error, Source As String, HelpFile As
              String, HelpContext As Long, CancelDisplay As Boolean)

Visual C++

void OnErrorDatatblctrl1(short Number, BSTR FAR* Description,
             SCODE Scode, LPCTSTR Source, LPCTSTR HelpFile,
             long HelpContext, BOOL FAR* CancelDisplay)

The Error event syntax has these parts:

Part	Description
Number	An integer specifing the error number.  (The code field extracted from the status code.)
Description	A string specifing a description of the error.
Scode	An unsigned long specifing the status code value.
Source	A string containg the name of the module generating the error.
HelpFile	A string containg the name of the help filecontaing a description of the error..
HelpContext	A long value specifing the Help ID of the error being reported.
CancelDisplay	A boolean value specifing whether to display the error message.  (Described in Settings)
Settings

The settings for CancelDisplay are:

Value	Description
True	Contine without displaying the error message.
False	(Default) Display the error message.


HScroll Event

Occurs when the DataTable has been scrolled horizontally.

Syntax

Visual Basic

Private Sub Datatbl1_HScroll()

Visual C++

void OnHScrollDatatblctrl1();


InsertedRow Event

Occurs when a row has been inserted.

Syntax

Visual Basic

Private Sub Datatbl1_InsertedRow(ByVal Row As Long)

Visual C++

void OnInsertedRowDatatblctrl1(long Row);

The InsertedRow event syntax has these parts:

Part	Description
Row	The row index of the new row.


KeyDown Event

Occurs when the user presses a key and the DataTable is NOT currently being edited.

Syntax

Visual Basic

Private Sub Datatbl1_KeyDown(keycode As Integer, shift As Integer)

Visual C++

void OnKeyDownDatatblctrl1(short FAR* KeyCode, short Shift)

The KeyDown event syntax has these parts:

Part	Description
KeyCode	An integer that represents the virtual key code of the pressed key. (Described in Settings)
shift	A bit field that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. (Described in Settings)
Settings

The keycode argument can be changed to simulate a different key being pressed.  Changing keycode to 0 cancels the key press.

The shift argument can have some, all, or none of the following bit masks set:

Constant	Bit	Value	Description
vbShiftMask	0	1	SHIFT key bit mask.
vbCTRLMask	1	2	CTRL key bit mask.
VbALTMask	2	4	ALT key bit mask
To test whether the SHIFT, CTRL or ALT key is pressed, perform an And operation between the shift argument and the bit mask and check if the results is equal to the bit mask.  The following example tests whether the SHIFT key is pressed.

Visual Basic

ShiftIsPressed = (shift And vbShiftMask) = vbShiftMask

Visual C++

ShiftIsPressed = (Shift & vbShiftMask) == vbShiftMask

Remarks

The KeyDown event is useful when you need to determine when function or navigational keys are pressed, since these keys do not fire a KeyPress event.


KeyPress Event

Occurs when the user presses and releases an ANSI key and the DataTable is NOT being edited.

Syntax

Visual Basic

Private Sub Datatbl1_KeyPress(keyascii As Integer)

Visual C++

void OnKeyPressDatatblctrl1(short FAR* KeyAscii)

The KeyPress event syntax has these parts:

Part	Description
keyascii	An integer that represents the ANSI keycode.
Remarks

The keyascii parameter can be changed to simulate a different character beinging entered.

Changing keyascii to 0 cancels the keystroke.

Visual basic users can convert the keyascii argument into a character by using the expression: char = Chr(keyascii). The character can later be converted back to an ANSI number using the expression:  keyascii = Asc(char).


KeyUp Event

Occurs when the user releases a key and the DataTable is NOT being edited.

Syntax

Visual Basic

Private Sub Datatbl1_KeyUp(keycode As Integer, shift As Integer)

Visual C++

void OnKeyUpDatatblctrl1(short FAR* KeyCode, short Shift)

The KeyUp event syntax has these parts:

Part	Description
KeyCode	An integer representing the virtual key code of the released key. (Described in Settings)
shift	A bit field that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. (Described in Settings)
Settings

The keycode argument can be changed to simulate a different key being released.

Changing keycode to 0 cancels the key release.

The shift argument can have some, all, or none of the following bit masks set:

Constant	Bit	Value	Description
vbShiftMask	0	1	SHIFT key bit mask.
vbCTRLMask	1	2	CTRL key bit mask.
VbALTMask	2	4	ALT key bit mask
To test whether the SHIFT, CTRL or ALT key is pressed, perform an And operation between the shift argument and the bit mask and check if the results is equal to the bit mask.  The following example tests whether the SHIFT key is pressed.

Visual Basic

ShiftIsPressed = (shift And vbShiftMask) = vbShiftMask

Visual C++

ShiftIsPressed = (Shift & vbShiftMask) == vbShiftMask


LfClick Event

Occurs when users presses the left mouse button.

Syntax

Visual Basic

Private Sub Datatbl1_LfClick(ByVal Pane As Integer,
            ByVal Row As Long, ByVal Column As Long,
            ByVal ClickPos As Long, Status As Long)

Visual C++

void OnLfClickDatatblctrl1(short Pane, long Row, long Column,
        long ClickPos, long FAR* Status);

The LfClick event syntax has these parts:

Part	Description
Pane	The pane index of the pane where the user clicked.
Row	The row index of the row where the user clicked.
Column	The column index of the column where the user clicked.
ClickPos	The location where the mouse was clicked.  (Described in Settings)
Status	The event return code.
Settings

The settings for Pane are:

Constant	Meaning
paneLabelTop	Row label column, Top Pane
paneLockedTop	Locked column pane, Top Pane
paneLeftTop	Left Pane, Top Pane
paneRightTop	Right Pane, Top Pane
paneLabelBottom	Row label column, Bottom Pane
paneLockedBottom	Locked column pane, Bottom Pane
paneLeftBottom	Left Pane, Bottom Pane
paneRightBottom	Right Pane, Bottom Pane
The settings for ClickPos are:

Setting	Description
posOnCell	Within a cell.
posOnHeading	Within the row used to display column headings.
posOnLabel	Within the column used for row numbers of row selection buttons.
posOnColGridLine	On the grid line between 2 columns.
posOnRowGridLine	On the grid line between 2 rows
posOnVertPaneLine	On the pane line that splits the table vertically
posOnHorzPaneLine	On the pane line that splits the table horizontally
posNoWhere	Anywhere else within the client area of the DataTable.
Remarks

If the Status argument is set to non zero while processing this event, the mouse left click is ignored.

See Also

MouseDown, MouseMove, MouseUp, LfDblClick, RtClick, RtDblClick


LfDblClick Event

The left mouse button was double clicked within the client area of a DataTable control.

Syntax

Visual Basic

Private Sub Datatbl1_LfDblClick(ByVal Pane As Integer,
            ByVal Row As Long, ByVal Column As Long,
            ByVal ClickPos As Long, Status As Long)

Visual C++

void OnLfDblClickDatatblctrl1(short Pane, long Row, long Column,
        long ClickPos, long FAR* Status);

The LfDblClick event syntax has these parts:

Part	Description
Pane	The pane index of the pane where the user clicked.
Row	The row index of the row where the user clicked..
Column	The column index of the column where the user clicked.
ClickPos	The location where the mouse was clicked.  (Described in Settings)
Status	The event return code.
Settings

The settings for Pane are:

Constant	Meaning
paneLabelTop	Row label column, Top Pane
paneLockedTop	Locked column pane, Top Pane
paneLeftTop	Left Pane, Top Pane
paneRightTop	Right Pane, Top Pane
paneLabelBottom	Row label column, Bottom Pane
paneLockedBottom	Locked column pane, Bottom Pane
paneLeftBottom	Left Pane, Bottom Pane
paneRightBottom	Right Pane, Bottom Pane

The settings for ClickPos are:

Setting	Description
posOnCell	Within a cell.
posOnHeading	Within the row used to display column headings.
posOnLabel	Within the column used for row numbers of row selection buttons.
posOnColGridLine	On the grid line between 2 columns.
posOnRowGridLine	On the grid line between 2 rows
posOnVertPaneLine	On the pane line that splits the table vertically
posOnHorzPaneLine	On the pane line that splits the table horizontally
posNoWhere	Anywhere else within the client area of the DataTable.
Remarks

If the Status argument is set to non zero while processing this event, the mouse left double click is ignored.

See Also

MouseDown, MouseMove, MouseUp, LfClick, RtClick, RtDblClick


MouseDown Event

Occur when the user has pressed a mouse button.

Syntax

Visual Basic

Private Sub Datatbl1_MouseDown(button As Integer, shift As Integer,
            x As Single, y As Single)

Visual C++

void OnMouseDownDatatblctrl1(short Button, short Shift, float x,
        float y)

The MouseDown event syntax has these parts:

Part	Description
button	An bit field that identifies the button that was pressed. (Described in Settings)
shift	An bit field that corresponds to the state of the SHIFT, CTRL, and ALT keys. (Described in Settings)
x	The current horizontal position of the mouse pointer expressed in terms of the containers coordinate system.
y	The current vertical position of the mouse pointer expressed in terms of the containers coordinate system.
Settings

The button argument has one of the following bit masks set.

Constant	Bit	Value	Description
vbLeftButton	0	1	Left button is pressed.
vbRightButton	1	2	Right button is pressed.
vbMiddleButton	2	4	Middle button is pressed.
Since the button argument can only be one of the bit masks, to test whether a button is pressed simply check if button is equal to the bit mask.

The shift argument can have some, all, or none of the following bit masks set:

Constant	Bit	Value	Description
vbShiftMask	0	1	SHIFT key bit mask.
vbCTRLMask	1	2	CTRL key bit mask.
VbALTMask	2	4	ALT key bit mask
To test whether the SHIFT, CTRL or ALT key is pressed, perform an And operation between the shift argument and the bit mask and check if the results is equal to the bit mask.  The following example tests whether the SHIFT key is pressed.

Visual Basic

ShiftIsPressed = (shift And vbShiftMask) = vbShiftMask

Visual C++

ShiftIsPressed = (Shift & vbShiftMask) == vbShiftMask

Remarks

The MouseDown event is useful when you need to determine the status of the SHIFT, CTRL, and ALT keys while processing a mouse click.

Use the DTCellSet objects GetCellAtPoint method to determine the pane, row and column index of the cell located at x, y.

See Also

MouseUp, MouseMove, LfClick, LfDblClick, RtClick, RtDblClick


MouseMove Event

Occurs when the user moves the mouse.

Syntax

Visual Basic

Private Sub Datatbl1_MouseMove(button As Integer, shift As Integer,
            x As Single, y As Single)

Visual C++

void OnMouseMoveDatatblctrl1(short Button, short Shift, float x,
        float y)

The MouseMove event syntax has these parts:

Part	Description
button	An integer that corresponds to the state of the mouse buttons. (Described in settings
shift	An bit field that corresponds to the state of the SHIFT, CTRL, and ALT keys. (Described in Settings)
x	A number that specifies the current location of the mouse pointer expressed in terms of the container coordinate system.
y	A number that specifies the current location of the mouse pointer expressed in terms of the container coordinate system.
Settings

The button argument can have some, all, or none of the following bit masks set:

Constant	Bit	Value	Description
vbLeftButton	0	1	Left button is pressed.
vbRightButton	1	2	Right button is pressed.
vbMiddleButton	2	4	Middle button is pressed.
To test whether a button is pressed, perform an And operation between the button argument and the bit mask and check if the results is equal to the bit mask.  The following example tests whether the left mouse button is pressed.

Visual Basic

LeftIsPressed = (button And vbLeftButton) = vbLeftButton

Visual C++

LeftIsPressed = (button & vbLeftButton) == vbLeftButton

The shift argument can have some, all, or none of the following bit masks set:

Constant	Bit	Value	Description
vbShiftMask	0	1	SHIFT key bit mask.
vbCTRLMask	1	2	CTRL key bit mask.
VbALTMask	2	4	ALT key bit mask
To test whether the SHIFT, CTRL or ALT key is pressed, perform an And operation between the shift argument and the bit mask and check if the results is equal to the bit mask.  The following example tests whether the SHIFT key is pressed.

Visual Basic

ShiftIsPressed = (shift And vbShiftMask) = vbShiftMask

Visual C++

ShiftIsPressed = (Shift & vbShiftMask) == vbShiftMask

Remarks

The MouseMove event is generated continually as the mouse pointer moves across the DataTable.

Use the DTCellSet objects GetCellAtPoint method to determine the pane, row and column index of the cell located at x, y.

See Also

MouseDown, MouseUp, LfClick, LfDblClick, RtClick, RtDblClick


MouseUp Event

 Occur when the user has released a mouse button.

Syntax

Visual Basic

Private Sub Datatbl1_MouseUp(button As Integer, shift As Integer,
            x As Single, y As Single)

Visual C++

void OnMouseUpDatatblctrl1(short Button, short Shift, float x, float y)

The MouseUp event syntax has these parts:

Part	Description
button	An bit field that identifies the button that was pressed. (Described in Settings)
shift	An bit field that corresponds to the state of the SHIFT, CTRL, and ALT keys. (Described in Settings)
x	The current horizontal position of the mouse pointer expressed in terms of the containers coordinate system.
y	The current vertical position of the mouse pointer expressed in terms of the containers coordinate system.
Settings

The button argument has one of the following bit masks set.

Constant	Bit	Value	Description
vbLeftButton	0	1	Left button is pressed.
vbRightButton	1	2	Right button is pressed.
vbMiddleButton	2	4	Middle button is pressed.
Since the button argument can only be one of the bit masks, to test whether a button is pressed simply check if button is equal to the bit mask.

The shift argument can have some, all, or none of the following bit masks set:

Constant	Bit	Value	Description
vbShiftMask	0	1	SHIFT key bit mask.
vbCTRLMask	1	2	CTRL key bit mask.
VbALTMask	2	4	ALT key bit mask
To test whether the SHIFT, CTRL or ALT key is pressed, perform an And operation between the shift argument and the bit mask and check if the results is equal to the bit mask.  The following example tests whether the SHIFT key is pressed.

Visual Basic

ShiftIsPressed = (shift And vbShiftMask) = vbShiftMask

Visual C++

ShiftIsPressed = (Shift & vbShiftMask) == vbShiftMask

Remarks

The MouseUp event is useful when you need to determine the status of the SHIFT, CTRL, and ALT keys while processing a mouse click.

Use the DTCellSet objects GetCellAtPoint method to determine the pane, row and column index of the cell located at x, y.

See Also

MouseDown, MouseMove, LfClick, LfDblClick, RtClick, RtDblClick


PaintCell Event

Occurs when a cell is about to be painted.

Syntax

Visual Basic

Private Sub Datatbl1_PaintCell(ByVal Pane As Integer,
           ByVal Row As Long, ByVal Column As Long, Status As Long)

Visual C++

void OnPaintCellDatatblctrl1(short Pane, long Row, long Column,
        long FAR* Status);

The PaintCell event syntax has these parts:

Part	Description
Row	The row index of the cell being painted..
Column	The column index of the cell being painted.
Pane	The pane of the cell being painted.
Status	The event return code.
Settings

The settings for Pane are:

Constant	Meaning
paneLabelTop	Row label column, Top Pane
paneLockedTop	Locked column pane, Top Pane
paneLeftTop	Left Pane, Top Pane
paneRightTop	Right Pane, Top Pane
paneLabelBottom	Row label column, Bottom Pane
paneLockedBottom	Locked column pane, Bottom Pane
paneLeftBottom	Left Pane, Bottom Pane
paneRightBottom	Right Pane, Bottom Pane
Remarks

This event is only sent if the EnablePaintCell property is set to true.

If the Status argument is set to non zero while processing this event, the DataTable will not paint the cell.


PosChange Event

Occurs when the current cells row or column index has changed.

Syntax

Visual Basic

Private Sub Datatbl1_PosChange(ByVal Row As Long,
            ByVal Column As Long)

Visual C++

void OnPosChangeDatatblctrl1(long Row, long Column);

The PosChange event syntax has these parts:

Part	Description
Row	The row index of the old current row.
Column	The column index of the old current column.
Remarks

The row and column index of the new current cell can be determined using the DTCurCell objects Row and Column properties.


RowChange Event

Occurs when the current cells row index has change.

Syntax

Visual Basic

Private Sub Datatbl1_RowChange(ByVal Row As Long)

Visual C++

void OnRowChangeDatatblctrl1(long Row);

The RowChange event syntax has these parts:

Part	Description
Row	The row index of the old current row.
Remarks

The row index of the new current cell can be determined using the DTCurCell objects Row property.


RowSel Event

Occurs when a row has been selected.

Syntax

Visual Basic

Private Sub Datatbl1_RowSel(ByVal Row As Long)

Visual C++

void OnRowSelDatatblctrl1(long Row);

The RowSel event syntax has these parts:

Part	Description
Row	The row index of the selected row.


RowSize Event

Occurs when a row has been resized.

Syntax

Visual Basic

Private Sub Datatbl1_RowSize(ByVal Row As Long)

Visual C++

void OnRowSizeDatatblctrl1(long Row);

The RowSize event syntax has these parts:

Part	Description
Row	The row index of the resized row.


RowUnSel Event

Occurs when a row has been deselected.

Syntax

Visual Basic

Private Sub Datatbl1_RowUnSel(ByVal Row As Long)

Visual C++

void OnRowUnSelDatatblctrl1(long Row);

The RowUnSel event syntax has these parts:

Part	Description
Row	The row index of the deselected row.


RtClick Event

Occurs when the user has clicked the right mouse button.

Syntax

Visual Basic

Private Sub Datatbl1_RtClick(ByVal Pane As Integer,
            ByVal Row As Long, ByVal Column As Long,
            ByVal ClickPos As Long, Status As Long)

Visual C++

void OnRtClickDatatblctrl1(short Pane, long Row, long Column,
        long ClickPos, long FAR* Status);

The RtClick event syntax has these parts:

Part	Description
Pane	The pane index of the pane where the user clicked.
Row	The row index of the row where the user clicked..
Column	The column index of the column where the user clicked.
ClickPos	The location where the mouse was clicked.  (Described in Settings)
Status	The event return code.
Settings

The settings for Pane are:

Constant	Meaning
paneLabelTop	Row label column, Top Pane
paneLockedTop	Locked column pane, Top Pane
paneLeftTop	Left Pane, Top Pane
paneRightTop	Right Pane, Top Pane
paneLabelBottom	Row label column, Bottom Pane
paneLockedBottom	Locked column pane, Bottom Pane
paneLeftBottom	Left Pane, Bottom Pane
paneRightBottom	Right Pane, Bottom Pane

The settings for ClickPos are:

Setting	Description
posOnCell	Within a cell.
posOnHeading	Within the row used to display column headings.
posOnLabel	Within the column used for row numbers of row selection buttons.
posOnColGridLine	On the grid line between 2 columns.
posOnRowGridLine	On the grid line between 2 rows
posOnVertPaneLine	On the pane line that splits the table vertically
posOnHorzPaneLine	On the pane line that splits the table horizontally
posNoWhere	Anywhere else within the client area of the DataTable.
Remarks

If the Status argument is set to non zero while processing this event, the mouse right click is ignored.

See Also

MouseDown, MouseMove, MouseUp, LfDblClick, LfClick, RtDblClick


RtDblClick Event

Occurs when the user has double clicked the right mouse button.

Syntax

Visual Basic

Private Sub Datatbl1_RtDblClick(ByVal Pane As Integer,
            ByVal Row As Long, ByVal Column As Long,
            ByVal ClickPos As Long, Status As Long)

Visual C++

void OnRtDblClickDatatblctrl1(short Pane, long Row,
        long Column, long ClickPos, long FAR* Status);

The RtDblClick event syntax has these parts:

Part	Description
Pane	The pane index of the pane where the user clicked.
Row	The row index of the row where the user clicked..
Column	The column index of the column where the user clicked.
ClickPos	The location where the mouse was clicked.  (Described in Settings)
Status	The event return code.
Settings

The settings for Pane are:

Constant	Meaning
paneLabelTop	Row label column, Top Pane
paneLockedTop	Locked column pane, Top Pane
paneLeftTop	Left Pane, Top Pane
paneRightTop	Right Pane, Top Pane
paneLabelBottom	Row label column, Bottom Pane
paneLockedBottom	Locked column pane, Bottom Pane
paneLeftBottom	Left Pane, Bottom Pane
paneRightBottom	Right Pane, Bottom Pane

The settings for ClickPos are:

Setting	Description
posOnCell	Within a cell.
posOnHeading	Within the row used to display column headings.
posOnLabel	Within the column used for row numbers of row selection buttons.
posOnColGridLine	On the grid line between 2 columns.
posOnRowGridLine	On the grid line between 2 rows
posOnVertPaneLine	On the pane line that splits the table vertically
posOnHorzPaneLine	On the pane line that splits the table horizontally
posNoWhere	Anywhere else within the client area of the DataTable.
Remarks

If the Status argument is set to non zero while processing this event, the mouse right double click is ignored.

The Row and Column parameters will have corresponding values to the ClickPos parameter.  For example,  if  ClickPos is posOnHeading, then Row will be dtHeadingsRow and Column will be the index of the column whose heading was clicked on.

See Also

MouseDown, MouseMove, MouseUp, LfClick, RtClick, LfDblClick


UpdateCell Event

 Occurs when edit mode is ending and the value of the current cell is about to be updated with the new value.

Syntax

Visual Basic

Private Sub Datatbl1_UpdateCell(ByVal Row As Long,
            ByVal Column As Long, Status As Long)

Visual C++

void OnUpdateCellDatatblctrl1(long Row, long Column,
        long FAR* Status);

The UpdateCell event syntax has these parts:

Part	Description
Row	The row index of the row being updated.
Column	The column index of the column being updated.
Status	The event return code.
Remarks

If the Status argument is set to non zero while processing this event, the original cell value is restored.

Reading the cell being updated while processing this event will return the original value.


VMGetFirst Event

 Occurs when the virtual memory table needs to retrieve the first row of data.

Syntax

Visual Basic

Private Sub Datatbl1_VMGetFirst(Status As Long)

Visual C++

void OnVMGetFirstDatatblctrl1( long FAR* Status);

The VMGetFirst event syntax has these parts:

Part	Description
Status	The event return code.
Remarks

The parent should process this event by:

1.	Setting the VMDataKey property to the data key of the first row.  (0 if using sequental keys.)

2.	Retrieving either a DTRow or DTCell object specifing VMDataKey as the row index and setting the row data using the objects Value property.

If the parent can not process this event, the parent must set Status to a non zero value.


VMGetLast Event

 Occurs when the virtual memory table needs to retrieve the last row of data.

Syntax

Visual Basic

Private Sub Datatbl1_VMGetLast(Status As Long)

Visual C++

void OnVMGetLastDatatblctrl1(long FAR* Status);

The VMGetLast event syntax has these parts:

Part	Description
Status	The event return code.
Remarks

The parent should process this event by:

1.	Setting the VMDataKey property to the last row.   (The number of rows minus one if using sequental keys.)

2.	Retrieving either a DTRow or DTCell object specifing VMDataKey as the row index and setting the row data using the objects Value property.

If the parent can not process this event, the parent must set Status to a non zero value.


VMGetNext Event

 Occurs when the virtual memory table needs to retrieve the next row of data.

Syntax

Visual Basic

Private Sub Datatbl1_VMGetNext(Status As Long)

Visual C++

void OnVMGetNextDatatblctrl1(long FAR* Status);

The VMGetNext event syntax has these parts:

Part	Description
Status	The event return code.
Remarks

The parent should process this event by:

1.	Setting the VMDataKey property to the row after the row currently specified by the VMDataKey property.  (Add one to VMDataKey if using sequental keys.)

2.	Retrieving either a DTRow or DTCell object specifing VMDataKey as the row index and setting the row data using the objects Value property.

If the parent can not process this event, the parent must set Status to a non zero value.


VMGetPercent Event

 Occurs when the virtual memory table needs to retrieve a row located a specified percentage down the table.

Syntax

Visual Basic

Private Sub Datatbl1_VMGetPercent(Status As Long)

Visual C++

void OnVMGetPercentDatatblctrl1(long FAR* Status);

The VMGetPercent event syntax has these parts:

Part	Description
Status	The event return code.
Remarks

The parent should process this event by:

1.	Setting the VMDataKey property to the row at the percentage currently specified by the VMDataKey property.  (Multiple VMDataKey by the number of rows and then divide by 100 if using sequental keys.)

2.	Retrieving either a DTRow or DTCell object specifing VMDataKey as the row index and setting the row data using the objects Value property.

If the parent can not process this event, the parent must set Status to a non zero value.


VMGetPrev Event

 Occurs when the virtual memory table needs to retrieve the previous row of data.

Syntax

Visual Basic

Private Sub Datatbl1_VMGetPrev(Status As Long)

Visual C++

void OnVMGetPrevDatatblctrl1(long FAR* Status);

The VMGetPrev event syntax has these parts:

Part	Description
Status	The event return code.
Remarks

The parent should process this event by:

1.	Setting the VMDataKey property to the row prior to the row currently specified by the VMDataKey property.  (Subtract one from VMDataKey if using sequental keys.)

2.	Retrieving either a DTRow or DTCell object specifing VMDataKey as the row index and setting the row data using the objects Value property.

If the parent can not process this event, the parent must set Status to a non zero value.


VMGetData Event
VMGetRowData Event

Occurs when the virtual memory table needs to retrieve a specific row of data.

Syntax

Visual Basic

Private Sub Datatbl1_VMGetRowData(Status As Long)

Visual C++

void OnVMGetRowDataDatatblctrl1(long FAR* Status);

The VMGetRowData event syntax has these parts:

Part	Description
Status	The event return code.
Remarks

The parent should process this event by:

1.	Retrieving either a DTRow or DTCell object specifing VMDataKey as the row index and setting the row data using the objects Value property.

If the parent can not process this event, the parent must set Status to a non zero value.


VScroll Event

Occurs when the DataTable has been scrolled vertically.

Syntax

Visual Basic

Private Sub Datatbl1_VScroll()

 Visual C++

void OnVScrollDatatblctrl1();


Appearance Constants

The following constants are used when setting or retrieving the three dimensional effect drawn.

Setting	Description
appearNone	None
appearHeavyIndent	Heavy Indent
appearShadow	Shadow
appearOutdent	Outdent
appearIndentFrame	Indent Frame
appearLightIndent	Light Indent

These constants are used by the DataTable objects Appearance property.


Color Constants

The following constant is used when setting and retrieving colors.

Constant	Description
dtDefaultColor	Indicates no color has been assigned, use the default color.


Data Edit Constants

The following constants are used when setting or retrieving whether the data in a particular column is editable.

Setting	Description
editDefault	(Default) The column data is editable if the DTCurCell objects Editable property is True.
editProtected	The column data is not editable.
editEditable	The column data is editable.

These constatns are used by the ColumnSet objects DataEdit property.


Data Type Constants

The following constants are used when setting or retrieving the data type of a column.

Setting	Description
dttShortInt	A short integer.
dttLongInt	A long integer.
dttSingleFloat	A single precision float.
dttDoubleFloat	A double precision float.
dttString	A string
dttDateTime	A date/time value.
dttChar	A character
dttCheckbox	A check box.
dttStdCheckbox	A standard check box.
dttCurrency	A currency value.
dttDate	A file date value.
dttTime	A file time value.
dttUShortInt	A unsigned short integer
dttULongInt	A unsigned long integer
dttBitmap	A bitmap

These constants are used by the ColumnSet objects DataType property.


Drop Down Constants

The following constants are used when setting or retrieving the type of drop down style enabled.

Setting	Description
ddNone	No Drop Down
ddDropDown	Drop Down
ddAutoDropDown	Auto Drop Down

These constants are used by the DataTable objects DropDownType property.


Focus Pen Style Constants

The following constants are used when setting or retrieving the focus pen style.

Constant	Meaning
fpDefault	Draw the default focus rectangle
fpSolid	Use a solid line.
fpDash	Use a dashed line. (Only valid when the focus pen width is 1.)
fpDot	Use a dotted line. (Only valid when the focus pen width is 1.)
fpDashDot	Use a line with alternating dashes and dots. (Only valid when the focus pen width is 1.)
fpDashDotDot	Use a line with alternating dashes and double dots  (Only valid when the focus pen width is 1.)
fpNull	Do not draw a focus rectangle

These constants are used by the CurCell objects FocusPenStyle property.


Heading Type Constants

The following constants are used when setting or retrieving the type of column headings displayed.

Setting	Description
headingsNone	No column headings are displayed.
headingsLetters	Columns are labeled with letters
headingsNumbers	Columns are labeled with numbers
headingsCustom	Column headings are specified by the DTColumn objects Heading property.

These constants are used by the RowSet objects HeadingType property.


Horizontal Alignment Constants

The following constants are used when setting or retrieving the horizontal alignment of column data.

Setting	Description
horzLeft	Left align the data.
horzCenter	Center the data.
horzRight	Right align the data.

These constants are used bythe ColumnSet objects DataAlign and HeadAlign properties.


Label Type Constants

The following constants are used when setting or retrieving the type of row labels displayed.

Setting	Description
labelsNone	No row label are displayed
labelsCustom	Row buttons are displayed.
labelsNumbers	Rows are labeled with sequential numbers.

These constants are used by the ColumnSet objects LabelType property.


Pane Constants

The following constants are used to specify a particular pane.

Constant	Meaning
paneLabelTop	Row label column, Top Pane
paneLockedTop	Locked column pane, Top Pane
paneLeftTop	Left Pane, Top Pane
paneRightTop	Right Pane, Top Pane
paneLabelBottom	Row label column, Bottom Pane
paneLockedBottom	Locked column pane, Bottom Pane
paneLeftBottom	Left Pane, Bottom Pane
paneRightBottom	Right Pane, Bottom Pane
paneLeft	Left Pane
paneRight	Right Pane
paneTop	Top Pane
paneBottom	Bottom Pane

These constants are used by the DTColumnSet objects FirstVisible property and GetVisCount method, the DTRowSet objects FirstVisible property and  GetVisCount method, the DTCellSet objects GetCellAtPoint method, the DTCell object GetRect method, and the DataTable LfClick, RtClick, LfDblClick, RtDblClick, and the PaintCell event.


Pane Size Constants

The following constant is used when setting and retrieving the left or top pane size.

Constant	Description
dtMaxPaneSize	The left or top pane is the maximum size.

This constant is used by the DataTable objects LeftPaneWidth and TopPaneHeight properties.


Position Constants

The following constants are used to describe where a particular point is in a DataTable.

Setting	Description
posOnCell	Within a cell.
posOnHeading	Within the row used to display column headings.
posOnLabel	Within the column used for row numbers of row selection buttons.
posOnColGridLine	On the grid line between 2 columns.
posOnRowGridLine	On the grid line between 2 rows
posOnVertPaneLine	On the pane line that splits the table vertically
posOnHorzPaneLine	On the pane line that splits the table horizontally
posNoWhere	Anywhere else within the client area of the DataTable.

These constants are used by the CellSet objects GetCellAtPoint method, and the DataTable events LfClick, LfDblClick, RtClick, and RtDblClick.


Resize Constants

The following constants are used to when setting or retrieving whether a row or column can be resized.

Setting	Description
resizeDefault	Resizing is allowed only if the resizing has been abled for all columns or rows.
resizeFixed	Resizing is not allowed.
resizeAdjustable	Resizing is allowed.

These constants are used by the Column and Row objects Resize property.


Row and Column Index Constants

The following constants are used to identify special rows and columns.

Constant	Description
dtLast	The last row or column
dtAfterLast	The imaginary row or column after the last row or column.
dtHeadingsRow	The row used to display column headings.
dtLabelsColumn	The column used to display row labels.


Scroll Bar Constants

The following constants are used when setting or retrieving the type of scroll bars displayed.

Constant	Description
sbNone	The DataTable never displays a scroll bar.
sbAutomatic	The DataTable displays a scroll bar when needed.
sbAlwaysOn	The DataTable always displays a scroll bar.

These constants are used by the DataTable objects HorzScrollBar and VertScrollBar properties.


Select Constants

The following constants are used when setting or retrieving the type of selection enabled.

Constant	Description
selectNone	Disable selection.
selectSingle	Enable single selection.
selectMultiple	Enable multiple selection

These constants are used by the RowSet, ColumnSet, and CellSet objects SelectType property.


Sort Key Constants

The following constants are used to specify a sort key.

Setting	Description
sortPrimary	Primary sort key
sortSecondary	Secondary sort key
sortTertiary	Tertiary sort key

These constants are used by the ColumnSet objects SortKey, SortAsc, and SortCaseI  properties.


Vertical Alignment Constants

The following constants are used when setting or retrieving the vertical   alignment of row data.

Setting	Description
vertTop	Align data to the top of the row.
vertCenter	Center data in the row.
vertBottom	Align data to the bottom of the row.

These constants are used by the RowSet objects VertAlign property.


Virtual Memory Type Constants

The following constants are used when setting or retrieveing the type of virtual memory model used.

Setting	Description
vmNone	No virtual memory model is used
vmIndexed	Virtual Memory with sequential keys
vmUserDefined	Virtual Memory with user defined keys.

These constants are used by the DataTable objects VirtualMemType property.