📄 baselist.cpp
字号:
// BaseList.cpp : implementation file
//
#include "stdafx.h"
#include "yhjk.h"
#include "BaseList.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// BaseList
BaseList::BaseList()
{
}
BaseList::~BaseList()
{
}
BEGIN_MESSAGE_MAP(BaseList, CListCtrl)
//{{AFX_MSG_MAP(BaseList)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// BaseList message handlers
bool BaseList::SetRecordset(RxRecordset rst)
{
CString sFieldName;
for(int m=0;m<rst.GetFieldCount();m++)
{
sFieldName=rst.GetFieldName(m);
this->InsertColumn(m,sFieldName);
}
AddCellText(rst);
return true;
}
void BaseList::PreSubclassWindow()
{
this->ModifyStyle(LVS_EDITLABELS,0L); //标题栏不可编辑
this->ModifyStyle(0L,LVS_REPORT);
this->ModifyStyle(0L,LVS_SHOWSELALWAYS); //高亮显示被选中项
this->SetExtendedStyle(LVS_EX_FULLROWSELECT| //允许整行选中
LVS_EX_HEADERDRAGDROP| //允许整列拖动
LVS_EX_GRIDLINES| //画出网格线
LVS_EX_ONECLICKACTIVATE| //单击选中项
LVS_EX_FLATSB); //扁平风格显示滚动条
CListCtrl::PreSubclassWindow();
}
void BaseList::AddCellText(RxRecordset rst)
{
int i,m;
CString sFieldName;
rst.MoveFirst();
this->DeleteAllItems();
for(i=0;i<rst.GetRecordCount();i++)
{
this->InsertItem(i,"");
}
for(i=0;i<rst.GetRecordCount();i++)
{
rst.Move(i);
for(m=0;m<rst.GetFieldCount();m++)
{
sFieldName=rst.GetFieldName(m);
this->SetItemText(i,m,rst.GetFieldValue(sFieldName));
}
}
for(m=0;m<rst.GetFieldCount();m++)
{
this->SetColumnWidth(m,LVSCW_AUTOSIZE_USEHEADER );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -