c++ 表格控件 UltimateGrid 控件实例

控件区域:

使用效果:

代码如下:

void MyUGCtrl::OnSetup()

{

m_nButtonIndex = AddCellType(&m_button);

SetNumberCols(6);

AppendRow();

CUGCell cell;

int rows, cols;

int row = 0;

// 头部

int nHeaderRow = -1;

{

QuickSetText(0, nHeaderRow, L"Button");

QuickSetAlignment(0, nHeaderRow, UG_ALIGNCENTER | UG_ALIGNVCENTER);

QuickSetText(1, nHeaderRow, L"Text");

QuickSetAlignment(1, nHeaderRow, UG_ALIGNCENTER | UG_ALIGNVCENTER);

QuickSetText(2, nHeaderRow, L"CheckBox");

QuickSetAlignment(2, nHeaderRow, UG_ALIGNCENTER | UG_ALIGNVCENTER);

QuickSetText(3, nHeaderRow, L"RadioButton");

QuickSetAlignment(3, nHeaderRow, UG_ALIGNCENTER | UG_ALIGNVCENTER);

SetRowHeight(nHeaderRow, 80);

QuickSetText(4, nHeaderRow, L"SpinButton");

QuickSetAlignment(4, nHeaderRow, UG_ALIGNCENTER | UG_ALIGNVCENTER);

QuickSetText(5, nHeaderRow, L"DateTime");

QuickSetAlignment(5, nHeaderRow, UG_ALIGNCENTER | UG_ALIGNVCENTER);

}

//button

{

GetCell(0, 0, &cell);

cell.SetText(L"Button");

cell.SetCellType(m_nButtonIndex);

cell.SetCellTypeEx(UGCT_BUTTONNOFOCUS);

cell.SetAlignment(UG_ALIGNCENTER | UG_ALIGNVCENTER);

cell.SetTextColor(RGB(0, 0, 128));

cell.SetBackColor(GetSysColor(COLOR_BTNFACE));

SetCell(0, 0, &cell);

SetRowHeight(0, 60);

}

//文本

{

QuickSetText(1, 0, L"Text");

QuickSetAlignment(1, 0, UG_ALIGNCENTER | UG_ALIGNVCENTER);

}

// checkbox

{

QuickSetCellType(2, 0, UGCT_CHECKBOX);

QuickSetCellTypeEx(2, 0, UGCT_CHECKBOXCHECKMARK /*| UGCT_CHECKBOX3DRAISED | UGCT_CHECKBOX3STATE*/);

QuickSetBackColor(2, 0, GetSysColor(COLOR_BTNFACE));

QuickSetLabelText(2, 0, L"Checkbox");

QuickSetAlignment(2, 0, UG_ALIGNCENTER | UG_ALIGNVCENTER);

}

// radiobutton

m_nRadioIndex = AddCellType(&m_radio);

{

cell.ClearAll();

GetCell(3, 0, &cell);

cell.SetLabelText(L"One\nTwo\n");

cell.SetCellType(m_nRadioIndex);

SetCell(3, 0, &cell);

QuickSetAlignment(3, 0, UG_ALIGNCENTER | UG_ALIGNVCENTER);

}

// SpinButton

m_nSpinIndex = AddCellType(&m_spin);

{

cell.ClearAll();

GetCell(4, 0, &cell);

cell.SetText(L"1");

cell.SetCellType(m_nSpinIndex);

cell.SetParam(SPIN_TYPE1);

SetCell(4, 0, &cell);

QuickSetAlignment(4, 0, UG_ALIGNCENTER | UG_ALIGNVCENTER);

}

//DateTime

m_nDateTimeIndex = AddCellType(&m_dateTime);

{

cell.ClearAll();

GetCell(5, 0, &cell);

cell.SetText(COleDateTime::GetCurrentTime().Format(VAR_DATEVALUEONLY));

cell.SetCellType(m_nDateTimeIndex);

SetCell(5, 0, &cell);

QuickSetAlignment(5, 0, UG_ALIGNCENTER | UG_ALIGNVCENTER);

}

}

相关推荐
让我们一起加油好吗5 小时前
【基础算法】初识搜索:递归型枚举与回溯剪枝
c++·算法·剪枝·回溯·洛谷·搜索
郝学胜-神的一滴5 小时前
Horse3D游戏引擎研发笔记(七):在QtOpenGL环境下,使用改进的Uniform变量管理方式绘制多彩四边形
c++·3d·unity·游戏引擎·图形渲染·虚幻·unreal engine
2401_876221347 小时前
Reachability Query(Union-Find)
c++·算法
躲着人群10 小时前
次短路&&P2865 [USACO06NOV] Roadblocks G题解
c语言·数据结构·c++·算法·dijkstra·次短路
一只鲲10 小时前
56 C++ 现代C++编程艺术5-万能引用
开发语言·c++
小欣加油11 小时前
leetcode 1493 删掉一个元素以后全为1的最长子数组
c++·算法·leetcode
争不过朝夕,又念着往昔12 小时前
即时通讯项目---网关服务
linux·c++·vscode
蓝风破云12 小时前
C++实现常见的排序算法
数据结构·c++·算法·排序算法·visual studio
怀旧,13 小时前
【C++】 9. vector
java·c++·算法
这儿有一堆花15 小时前
C++标准库算法:从零基础到精通
c++