All,
In an existing C++/MFC application I'm using ADO+Microsoft DataGrid Control.
At the moment I need to creat tree-like view in the grid (like in Microsoft Access when viewing
related tables).
Below is the code illustrating how I bind grid to ADO recordset (m_pGrid is an object of wrapper-class CDataGrid):
C_Recordset& rc=m_ctlADODC.GetRecordset();
m_pGrid.SetRefDataSource(NULL);
m_pGrid.SetRefDataSource(rc);
m_pGrid.SetAllowAddNew(FALSE);// allow empty '*'-field at top
m_pGrid.SetAllowUpdate(FALSE);// disallow editing current records
m_pGrid.SetAllowDelete(FALSE);// disallow deleting by pressing Del (???)
m_pGrid.SetAllowArrows(TRUE); // allow arrows keys (???)
m_pGrid.Refresh();
m_pGrid.UpdateData();
And the following is the way i use to open ADO data source (m_ctlADODC encapsulates Microsoft ADODC Control,
an object of wrapper-class CAdodc):
CHAR szTemp[256];
::sprintf(szTemp,"SELECT * FROM [%s] ORDER BY [%s]",table_db_dao,field_id);
m_ctlADODC.SetConnectionString(NULL);
m_ctlADODC.SetMaxRecords(ADODC_MAX_RECORDS);
m_ctlADODC.SetCacheSize(ADODC_CACHE_SIZE);
m_ctlADODC.SetRecordSource(NULL);
lstrcat(szConnectionString,GetDocument()->GetPathName());
lstrcat(szConnectionString,_T(";"));
m_ctlADODC.SetConnectionString(szConnectionString);
m_ctlADODC.SetRecordSource(_T(szTemp));
m_ctlADODC.SetCursorType(adOpenDynamic);
// don't use adLockBatchOptimistic since Grid refresh works badly with it
m_ctlADODC.SetLockType(adLockOptimistic);
m_ctlADODC.SetCommandType(adCmdTable);
// use adCmdTable for table command type
m_ctlADODC.SetCommandType(adCmdText);
m_ctlADODC.SetBackColor(ADODC_COLOR);
m_ctlADODC.SetCaption(_T("Navigation"));
// if here an error with code DISP_E_EXCEPTION=0x80020009 occurs, check
// the Connection String for invalid value
m_ctlADODC.Refresh();
What should I do to use tree view and multiple data sources?
Thanks a lot in advance.....
In an existing C++/MFC application I'm using ADO+Microsoft DataGrid Control.
At the moment I need to creat tree-like view in the grid (like in Microsoft Access when viewing
related tables).
Below is the code illustrating how I bind grid to ADO recordset (m_pGrid is an object of wrapper-class CDataGrid):
C_Recordset& rc=m_ctlADODC.GetRecordset();
m_pGrid.SetRefDataSource(NULL);
m_pGrid.SetRefDataSource(rc);
m_pGrid.SetAllowAddNew(FALSE);// allow empty '*'-field at top
m_pGrid.SetAllowUpdate(FALSE);// disallow editing current records
m_pGrid.SetAllowDelete(FALSE);// disallow deleting by pressing Del (???)
m_pGrid.SetAllowArrows(TRUE); // allow arrows keys (???)
m_pGrid.Refresh();
m_pGrid.UpdateData();
And the following is the way i use to open ADO data source (m_ctlADODC encapsulates Microsoft ADODC Control,
an object of wrapper-class CAdodc):
CHAR szTemp[256];
::sprintf(szTemp,"SELECT * FROM [%s] ORDER BY [%s]",table_db_dao,field_id);
m_ctlADODC.SetConnectionString(NULL);
m_ctlADODC.SetMaxRecords(ADODC_MAX_RECORDS);
m_ctlADODC.SetCacheSize(ADODC_CACHE_SIZE);
m_ctlADODC.SetRecordSource(NULL);
lstrcat(szConnectionString,GetDocument()->GetPathName());
lstrcat(szConnectionString,_T(";"));
m_ctlADODC.SetConnectionString(szConnectionString);
m_ctlADODC.SetRecordSource(_T(szTemp));
m_ctlADODC.SetCursorType(adOpenDynamic);
// don't use adLockBatchOptimistic since Grid refresh works badly with it
m_ctlADODC.SetLockType(adLockOptimistic);
m_ctlADODC.SetCommandType(adCmdTable);
// use adCmdTable for table command type
m_ctlADODC.SetCommandType(adCmdText);
m_ctlADODC.SetBackColor(ADODC_COLOR);
m_ctlADODC.SetCaption(_T("Navigation"));
// if here an error with code DISP_E_EXCEPTION=0x80020009 occurs, check
// the Connection String for invalid value
m_ctlADODC.Refresh();
What should I do to use tree view and multiple data sources?
Thanks a lot in advance.....