我现在使用CGridCtrl表格类时遇到些麻烦的问题请大家帮忙看看,谢谢!

myzcp123 2009-05-09 02:40:48
我在一个只有一个对话框的工程中使用时能正常的把CELL设置成combo或checkbox等,但在有tab ctrl的对话框中则不能正常,更详细情况请大家看图片

编译出错的的信息

--------------------Configuration: TabControl - Win32 Debug--------------------
Linking...
EditPage.obj : error LNK2001: unresolved external symbol "public: void __thiscall CGridCellCombo::SetOptions(class CStringArray const &)" (?SetOptions@CGridCellCombo@@QAEXABVCStringArray@@@Z)
EditPage.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CGridCellCombo::classCGridCellCombo" (?classCGridCellCombo@CGridCellCombo@@2UCRuntimeClass@@B)
Debug/TabControl.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
TabControl.exe - 3 error(s), 0 warning(s)


void CEditPage::InitEditGridForm()
{
CString strIndex="";
int i;
// MoveWindow(0,0,780,520);
CRect Rect;
GetClientRect(&Rect);
this->GetParent()->GetWindowRect(&Rect);
MoveWindow(&Rect);
GetClientRect(&Rect);
Rect.top += 1;
Rect.bottom -= 22;
Rect.left += 0;
Rect.right -=5;
m_GridForm.MoveWindow(Rect);
m_GridForm.SetRowCount(GRID_ROW_COUNT);
m_GridForm.SetColumnCount(GRID_COLUM_COUNT);
m_GridForm.SetFixedColumnCount(1);
m_GridForm.SetFixedColumnSelection(FALSE);//设置能否整列选择
m_GridForm.SetColumnWidth(0,30);

/*
for(i=1;i<GRID_ROW_COUNT;i++)//设置为ComBo
{
m_GridForm.SetCellType(i,1,RUNTIME_CLASS(CGridCell));
m_GridForm.SetItemState(i,1, m_GridForm.GetItemState(1,1) & ~GVIS_READONLY);
m_GridForm.SetCellType(i,1, RUNTIME_CLASS(CGridCellCombo));

m_options.Add(_T("1.项目1"));
m_options.Add(_T("2.项目2"));
m_options.Add(_T("3.项目3"));
m_options.Add(_T("4.项目4"));
m_options.Add(_T("5.项目5"));
CGridCellCombo *pCell = (CGridCellCombo*) m_GridForm.GetCell(i,1);
pCell->SetOptions(m_options);
pCell->SetStyle(CBS_DROPDOWNLIST); //CBS_DROPDOWN, CBS_DROPDOWNLIST, CBS_SIMPLE
m_GridForm.Invalidate();
}
*/

for(i=0;i<GRID_ROW_COUNT;i++) //设置行高
{
m_GridForm.SetRowHeight(i,22);
}
m_GridForm.SetFixedBkColor(RGB(236,236,236));
m_GridForm.SetFixedRowCount(1);
m_GridForm.SetFixedRowSelection(TRUE);//设置能否整行选择
m_GridForm.SetTextBkColor(RGB(210,245,255));
m_GridForm.SetTextColor(RGB(7,48,9));

for(i=0;i<GRID_ROW_COUNT;i++)
{
strIndex.Format("%u",i);
m_GridForm.SetItemText(i,0,strIndex);
}
for(i=0;i<GRID_COLUM_COUNT;i++)
{
strIndex.Format("%u",i);
m_GridForm.SetItemText(0,i,strIndex);
}
Invalidate();
UpdateWindow();
}

...全文
424 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
blueicescape 2011-02-17
  • 打赏
  • 举报
回复
把m_GridForm声明为指针,然后在TabCtrl中new一个,再试试?
biweilun 2009-05-11
  • 打赏
  • 举报
回复
晕....灵异
wocow3 2009-05-11
  • 打赏
  • 举报
回复
link错误确实诡异,CGridCtrl直接提供源码,不存在lib的问题。你看看有没有宏开关的需要预定义一下
myzcp123 2009-05-11
  • 打赏
  • 举报
回复

现在整了个图片过来帮忙看看
图的上半部份是将CGridCtrl放在TabCtrl上的,就不能将单元格设置为combo等,否则会error link 2001
下半部份则是单独一个对话框的工程则完全无问题
myzcp123 2009-05-10
  • 打赏
  • 举报
回复
昨天试了,结果是ProperSheet无法建立,原因可能是CGridCtrl这个类的使用方法引起的,
使用方法如下:
1.在需要的对话框中加入一个custom control,将class设为 MFCGridCtrl
2.在工程中加入需要的.cpp a和 .h 文件,这些文件都在gridctrl_src225.zip里,解压后放在程序目录下
3.在需要加入控件的对话框类的声明文件中加#include "GridCtrl.h",在对话框类里定义'CGridCtrl m_gridCtrl'变量
4.在对话的 cpp文件中的DoDataExchange()中加入DDX_Control(pDX,定制控件的ID,m_gridCtrl)编译运行即可
在ProperSheet中的ProperPage对话框中只要放入了一个"CustomControl"控件ProperSheet就无法运行了!
这个类的下载地址:http://www.codeproject.com/KB/miscctrl/gridctrl.aspx



myzcp123 2009-05-09
  • 打赏
  • 举报
回复
好的,现在试试看!
biweilun 2009-05-09
  • 打赏
  • 举报
回复
照理说没问题的,你换成CPropertySheet试试看,不用CTabCtrl

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧