Type | Description | |||
Object | An Object that defines the control's data. Currently, the control accepts ADO.Recordset, ADODB.Recordset objects, DAO recordsets |
The /NET version provides the following methods for data binding:
Click here to watch a movie on how to assign a data source to the control, in design mode, for /NET assembly.
The DataSource property can load all data in the memory or just visible records ( virtual mode ). The VirtualMode property indicates whether the control loads all records in memory or just visible records. If the VirtualMode property is False ( by default ), all records are loaded in memory. The user must call the VirtualMode property before setting the DataSource, else an error occurs. If the VirtualMode property is True, before specifying the DataSource, the control loads virtually the records, just visible records are loaded. Use the control's virtual mode when you require to display and edit large databases, and you don't want to load the entire database in memory. Aldo, running the virtual mode disables some features including sorting and filtering, like explained in the VirtualMode property. The control builds an internal object that implements the IUnboundHandler interface that provides data for the control, when running in virtual mode, so the UnboundHandler property is not empty.
The following template script loads virtually the Order table, using the Template feature of the control ( copy the following template and paste it to the control's WYSWYG Template editor ) ( the sample uses Jet.OLEDB provider to handle MDB files ) :
Dim rs VirtualMode = True ColumnAutoResize = False rs = CreateObject("ADOR.Recordset") { Open("Orders","Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Exontrol\ExList\Sample\SAMPLE.MDB", 3, 3 ) } DataSource = rs ConditionalFormats { Add("%1 > 4").Bold = True Add("%1 = 1 or %1 = 3") { Underline = True ForeColor = RGB(255,0,0) ApplyTo = 1 } }
or ( the sample uses VFPOLEDB provider to handle DBF files )
Dim rs VirtualMode = True ColumnAutoResize = False rs = CreateObject("ADODB.Recordset").Open("Select * from Students","Provider=vfpoledb;Data Source=D:\Program Files\Microsoft Visual Studio\Vfp98\Wizards\Template\Students And Classes\Data\STUDENTS AND CLASSES.DBC;Collating Sequence=machine"1,1 ) DataSource = rs
Use the Caption property to retrieves the value of the cell. Use the PutItems to load an array to the control. If the VirtualMode property is False, the DetectAddNew detects when a new record is added to the recordset and updates the control's list so the new record is included. Use the ConditionalFormats method to apply formats to a cell or range of cells, and have that formatting change depending on the value of the cell or the value of a formula.
The following VB sample binds an ADO recordset to the ExList control:
Set rs = CreateObject("ADODB.Recordset") rs.Open "Orders", "Provider=Microsoft.Jet.OLEDB.3.51;Data Source= D:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB", 3 ' Opens the table using static mode Set List1.DataSource = rs
The DataSource clears the columns collection, and fill the record set into the list.
The following C++ sample binds a table to the control:
#include "Items.h" #include "Columns.h" #include "Column.h" #pragma warning( disable : 4146 ) #import <msado15.dll> rename ( "EOF", "adoEOF" ) using namespace ADODB; _RecordsetPtr spRecordset; if ( SUCCEEDED( spRecordset.CreateInstance( "ADODB.Recordset") ) ) { // Builds the connection string. CString strTableName = "Employees", strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="; CString strPath = "D:\\Program Files\\Microsoft Visual Studio\\VB98\\NWIND.MDB"; strConnection += strPath; try { // Loads the table if ( SUCCEEDED( spRecordset->Open(_variant_t( (LPCTSTR)strTableName ), _variant_t((LPCTSTR)strConnection), adOpenStatic, adLockPessimistic, NULL ) ) ) { m_list.BeginUpdate(); m_list.SetColumnAutoResize( FALSE ); m_list.SetDataSource( spRecordset ); m_list.EndUpdate(); } } catch ( _com_error& e ) { AfxMessageBox( e.Description() ); } }
The #import statement imports definitions for ADODB type library, that's used to fill the control