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

}

}

相关推荐
爱学习的小邓同学19 分钟前
c++ --- priority_queue的使用以及简单实现
c++
清朝牢弟2 小时前
Ubuntu系统VScode实现opencv(c++)视频的处理与保存
c++·人工智能·vscode·opencv·ubuntu
oioihoii2 小时前
在macOS上使用VS Code和Clang配置C++开发环境
c++·macos·策略模式
科大饭桶3 小时前
C++入门自学Day5-- C/C++内存管理(续)
c语言·开发语言·c++
lzb_kkk3 小时前
【实习总结】Qt通过Qt Linguist(语言家)实现多语言支持
开发语言·c++·qt·1024程序员节·qt linguist·qt 语言家
ZLRRLZ3 小时前
【数据结构】哈希表实现
数据结构·c++·散列表
weixin_307779134 小时前
ClickHouse Windows迁移方案与测试
linux·c++·数据仓库·windows·clickhouse
老猿讲编程4 小时前
LCM中间件入门(1):工作原理核心概念及Ubuntu环境下的C++实践
c++·ubuntu·中间件·lcm
爱掉发的小李5 小时前
Linux 环境下 Docker 安装与简单使用指南
java·linux·运维·c++·python·docker·php
澄澈i6 小时前
设计模式学习[17]---组合模式
c++·学习·设计模式·组合模式