RE: function template
Hi Manjree,
Thanks for your email and sending me your sample project.
This indeed helped me reproduce your issue at my side. From my research,
it seemed to be a product issue when a function template (or a class
template) was declared in one file and implemented in another file.
I am trying to consult the Dev team to confirm this. If there is any
response, I will let you know.
Now, as a workaround, I recommend that include both of the function
template declaration and implementation in the header file ListCtrlSetup.h.
For example:
//--ListCtrlSetup.h-------------------------------------------------
#pragma once
#include "stdAfx.h"
#include "CheckListCtrl.h"
ref class CListCtrlSetup
{
public:
CListCtrlSetup(void);
template<class T>
void InsColumn(T& lst, System::Data::DataTable^ table)
{
try
{
DataColumnCollection^ columns = table->Columns;
DataColumn^ column;
CString str;
int i, col = columns->Count;
for(i=0; i<col; i++){
column = columns[i];
str = column->ColumnName;
lst.InsertColumn(i, str);
}
SetColWidth(lst);
}
catch(Exception^ e)
{
MessageBox::Show(e->Message, L".NET Exception Thrown",
MessageBoxButtons::OK,
MessageBoxIcon::Error);
}
}
// Set the widths for the list columns
template<class U> void SetColWidth(U& lst)
{
try
{
int nColumnCount =
lst.GetHeaderCtrl()->GetItemCount();
//Set the column width for all the columns
for(int i=0; i<nColumnCount; i++)
lst.SetColumnWidth(i,
LVSCW_AUTOSIZE_USEHEADER);
}
catch(Exception^ e)
{
MessageBox::Show(e->Message, L".NET
Exception Thrown",
MessageBoxButtons::OK,
MessageBoxIcon::Error);
}
}
void InsItem(CListCtrl& lst, DataTable^ table,int initRow);
void InsItem(CCheckListCtrl& lst, DataTable^ table,int
initRow);
void DeleteAllColumns(CListCtrl& lst);
int GetSelectedItem(CListCtrl& lst);
};
//--------------------------------------------------------------------------
--------
If you have any other questions or concerns, please feel free to let me
know. It is my pleasure to be of assistance.
Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================