Click here to Skip to main content
15,903,012 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: DAO/ADO/ODBC Pin
Tara142-Aug-06 21:14
Tara142-Aug-06 21:14 
GeneralRe: DAO/ADO/ODBC Pin
Jonathan [Darka]2-Aug-06 21:21
professionalJonathan [Darka]2-Aug-06 21:21 
GeneralRe: DAO/ADO/ODBC Pin
Tara142-Aug-06 21:29
Tara142-Aug-06 21:29 
GeneralRe: DAO/ADO/ODBC Pin
Jonathan [Darka]2-Aug-06 21:31
professionalJonathan [Darka]2-Aug-06 21:31 
GeneralRe: DAO/ADO/ODBC Pin
Tara142-Aug-06 21:50
Tara142-Aug-06 21:50 
AnswerRe: DAO/ADO/ODBC Pin
Viorel.2-Aug-06 21:26
Viorel.2-Aug-06 21:26 
GeneralRe: DAO/ADO/ODBC Pin
Tara142-Aug-06 21:32
Tara142-Aug-06 21:32 
GeneralRe: DAO/ADO/ODBC [modified] Pin
Phil.Benson3-Aug-06 0:05
professionalPhil.Benson3-Aug-06 0:05 
Tara14 wrote:
I did search for virtual lists, but from what I gathered, it looked like one cannot do many things with virtual lists - for example: sorting cannot be done.


This is not true. If you create a virtual list, you must handle the displaying of the data, and you can also handle the column click, call the requery function of the table and then invalidate the list control.

For example: Override the listviews column click virtual method...

void YourListControlView::OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult){

if(NULL == pYourTable){
return;
}

*pResult = 1;
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
ASSERT(pNMLV);

CString _sOrderBy;
CString _sOrder;
CString _sFieldName;
CDaoFieldInfo info;
ZeroMemory(&info, sizeof(CDaoFieldInfo));

m_bSortAscending = (m_nSortColumn != pNMLV->iSubItem) ? true : !m_bSortAscending;
m_nSortColumn = pNMLV->iSubItem;

if(m_bSortAscending){
_sOrder = _T(" ASC");
}
else{
_sOrder = _T(" DESC");
}

try{
pYourTable->GetFieldInfo(nSortColumn, info);
_sFieldName = info.m_strName;

_sOrderBy.Format(_T("%s %s"), _sFieldName, _sOrder);

// Requery the table
// *****************
pYourTable->m_strSort = _sOrderBy;
pYourTable->m_strFilter = _T(""); // You may need to change this !!
pYourTable->Requery();
pYourTable->MoveFirst();
}
catch(CDaoException* px_e){
#ifdef _DEBUG
px_e->ReportError();
#endif
px_e->Delete();
}



// Invalidate the list control so
// that it will be refreshed
// ******************************
GetListCtrl().Invalidate();

....

}

This assumes that your table class is derived from CDaoRecordSet. I use my own classes for DAO access, and any of the main functions (Requery, Movexx etc are capsled)

In this example, I have two member variablesto keep track of the current column and the order of sorting (m_nSortColumn, m_bSortAscending)

Also, using GetListCtrl().SetItemCountEx(nNumberOfRecordsPresnet) will speed up the displaying of the data.

Hope this helps a bit
mfg
Phil



Who the f*** is General Failure, and why is he reading my harddisk?


-- modified at 6:06 Thursday 3rd August, 2006
GeneralRe: DAO/ADO/ODBC Pin
Tara143-Aug-06 1:54
Tara143-Aug-06 1:54 
GeneralRe: DAO/ADO/ODBC Pin
Phil.Benson3-Aug-06 2:17
professionalPhil.Benson3-Aug-06 2:17 
GeneralRe: DAO/ADO/ODBC Pin
Tara143-Aug-06 22:19
Tara143-Aug-06 22:19 
GeneralRe: DAO/ADO/ODBC Pin
Tara142-Aug-06 21:48
Tara142-Aug-06 21:48 
Questionget date from COleDateTime Pin
Sam_the_xalan2-Aug-06 20:21
Sam_the_xalan2-Aug-06 20:21 
AnswerRe: get date from COleDateTime Pin
Steve Echols2-Aug-06 21:12
Steve Echols2-Aug-06 21:12 
QuestionFile does not open Pin
Ratish Philip2-Aug-06 19:52
Ratish Philip2-Aug-06 19:52 
AnswerRe: File does not open Pin
Christian Graus2-Aug-06 19:58
protectorChristian Graus2-Aug-06 19:58 
AnswerRe: File does not open Pin
toxcct2-Aug-06 20:45
toxcct2-Aug-06 20:45 
AnswerRe: File does not open Pin
Sarath C2-Aug-06 21:22
Sarath C2-Aug-06 21:22 
QuestionQuestion: @ DavidCrow about NetUserGetInfo() Pin
Programm3r2-Aug-06 19:50
Programm3r2-Aug-06 19:50 
AnswerRe: Question: @ DavidCrow about NetUserGetInfo() Pin
Hamid_RT2-Aug-06 20:28
Hamid_RT2-Aug-06 20:28 
QuestionRe: Question: @ DavidCrow about NetUserGetInfo() Pin
Programm3r2-Aug-06 20:39
Programm3r2-Aug-06 20:39 
AnswerRe: Question: @ DavidCrow about NetUserGetInfo() Pin
ThatsAlok2-Aug-06 22:03
ThatsAlok2-Aug-06 22:03 
AnswerRe: Question: @ DavidCrow about NetUserGetInfo() Pin
toxcct2-Aug-06 20:43
toxcct2-Aug-06 20:43 
QuestionRe: Question: @ DavidCrow about NetUserGetInfo() Pin
Programm3r2-Aug-06 20:49
Programm3r2-Aug-06 20:49 
AnswerRe: Question: @ DavidCrow about NetUserGetInfo() Pin
toxcct2-Aug-06 20:55
toxcct2-Aug-06 20:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.