⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grid.cpp

📁 一个关于MSFlexGrid使用的例子,能够进行表格的编辑等操作
💻 CPP
字号:
// m_Grid->cpp: implementation of the CGrid class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "FlexGrid.h"
#include "grid.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CGrid ::CGrid()
{

	
	
}


CGrid ::~CGrid()
{

}


BOOL CGrid ::GoUp()
 
{
	
	TransferValue(TRUE);
	if (GetRow () > 1 ) {
		int CurrentRow = GetRow();
		CurrentRow --;
		SetRow (CurrentRow );
		TransferValue (FALSE);
		if (! GetRowIsVisible (CurrentRow)) 
            SetTopRow (CurrentRow  );

	}
	return TRUE;

	
}


BOOL CGrid ::GoDown()
{
	
	TransferValue(TRUE);
	if ( GetRow () < GetRows () -1) {
		int CurrentRow = GetRow();
		CurrentRow ++;
		SetRow ( CurrentRow);
		TransferValue (FALSE);
		if (! GetRowIsVisible (CurrentRow)) 
            SetTopRow (CurrentRow );
	}


	return TRUE;

}


BOOL CGrid ::GoLeft()
{
	
	TransferValue(TRUE);
	if ( GetCol () > 1 ) {
		int CurrentCol = GetCol();
		CurrentCol --;
		SetCol (CurrentCol);
		TransferValue (FALSE);
		if (!GetColIsVisible (CurrentCol))
			 SetLeftCol (CurrentCol);
	}
 return TRUE;


}


BOOL CGrid ::GoRight()
{
	
	TransferValue(TRUE);
	if ( GetCol () < GetCols() - 1 ) {
		int CurrentCol = GetCol ();
		CurrentCol++;
		SetCol (CurrentCol);
		TransferValue (FALSE);
		if (!GetColIsVisible (CurrentCol))
			 SetLeftCol (CurrentCol);
		
	}
	
	return TRUE;
}



BOOL CGrid ::TransferValue(BOOL ToGrid)
{
	CString sText;

	if (ToGrid) { //Transfer value to Grid from Edit Box
		SetText(m_GridData  );
	} else {
		m_GridData  = GetText ();
		SetBackColorSel  (RGB(0,255,255));
	}
	return TRUE;
}



BOOL CGrid ::OnKeyPressGrid(short FAR* KeyAscii) 
{

	   switch ( (int) * KeyAscii) {

			case  VK_BACK : //Backspace - delete the last character
				  m_GridData.Delete  (m_GridData.GetLength ()-1,1);
		          break;
			default :
				  m_GridData = m_GridData + (TCHAR *) KeyAscii;
			      break;
	   }
	   TransferValue (TRUE);
}


CGrid ::OnClickGrid()
{

	TransferValue (FALSE);
	 
}


void CGrid::OnEnterCell()
{
	TransferValue (FALSE);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -