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);

}

}

相关推荐
你的冰西瓜10 分钟前
C++ 中最短路算法的详细介绍
c++·算法·图论·最短路
<但凡.25 分钟前
数据结构与算法之美:广义表
数据结构·c++·算法
大白的编程日记.2 小时前
【计算机基础理论知识】C++篇(二)
开发语言·c++·学习
C语言小火车2 小时前
野指针:C/C++内存管理的“幽灵陷阱”与系统化规避策略
c语言·c++·学习·指针
凤年徐2 小时前
【数据结构】时间复杂度和空间复杂度
c语言·数据结构·c++·笔记·算法
踏莎行hyx3 小时前
使用langchain连接llama.cpp部署的本地deepseek大模型开发简单的LLM应用
c++·ai·langchain·大模型·llama.cpp·deepseek
山河木马3 小时前
前端学C++可太简单了:双冒号 :: 操作符
前端·javascript·c++
乌萨奇也要立志学C++4 小时前
【C++详解】STL-list模拟实现(深度剖析list迭代器,类模板未实例化取嵌套类型问题)
c++·list
闻缺陷则喜何志丹4 小时前
【前缀和 BFS 并集查找】P3127 [USACO15OPEN] Trapped in the Haybales G|省选-
数据结构·c++·前缀和·宽度优先·洛谷·并集查找
序属秋秋秋5 小时前
《C++初阶之内存管理》【内存分布 + operator new/delete + 定位new】
开发语言·c++·笔记·学习