?? extendedit_grid.cpp
字號:
// ExtendEdit_Grid.cpp : implementation file
//
#include "stdafx.h"
#include "商品庫存管理系統.h"
#include "ExtendEdit_Grid.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern _ConnectionPtr cnn;
extern CMyApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CExtendEdit_Grid
CExtendEdit_Grid::CExtendEdit_Grid()
{
}
CExtendEdit_Grid::~CExtendEdit_Grid()
{
}
BEGIN_MESSAGE_MAP(CExtendEdit_Grid, CListCtrl)
//{{AFX_MSG_MAP(CExtendEdit_Grid)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExtendEdit_Grid message handlers
void CExtendEdit_Grid::SetRecordset(_RecordsetPtr pRst)
{
this->rst=pRst;
//添加列標題
CString FieldName;
for(int j=0;j<rst->GetFields()->GetCount();j++)
{
FieldName=(char*)(_bstr_t)rst->GetFields()->GetItem((long)j)->Name;
InsertColumn(j,FieldName);
}
this->m_Cols=j;
//添加行
for(int i=0;i<theApp.GetRecordCount(rst);i++)
{
this->InsertItem(i,"");
}
//顯示記錄
this->Refresh();
//調整列寬
for(j=0;j<rst->GetFields()->GetCount();j++)
{
SetColumnWidth(j,LVSCW_AUTOSIZE);
}
}
void CExtendEdit_Grid::Refresh()
{
if(theApp.GetRecordCount(rst)<0)
Clear();
else
{
this->DeleteAllItems();
for(int i=0;i<theApp.GetRecordCount(rst);i++)
{
this->InsertItem(i,"");
}
CString CellText;
for( i=0;i<theApp.GetRecordCount(rst);i++)
{
rst->MoveFirst();
rst->Move(i);
for(int j=0;j<rst->GetFields()->GetCount();j++)
{
CellText=(char*)(_bstr_t)rst->GetFields()->GetItem((long)j)->Value;
SetItemText(i,j,CellText);
}
}
}
}
void CExtendEdit_Grid::Clear()
{
this->DeleteAllItems();
}
void CExtendEdit_Grid::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();
}
int CExtendEdit_Grid::GetColumnCount()
{
return m_Cols;
}
void CExtendEdit_Grid::SetColumnCount(int nCol)
{
m_Cols=nCol;
}
void CExtendEdit_Grid::DeleAllCol()
{
int cols=this->GetColumnCount();
for(int i=0;i<=cols+1;i++)
{
this->DeleteColumn(0);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -