gpt4 book ai didi

c++ - 标题中的多行文本

转载 作者:行者123 更新时间:2023-12-03 12:51:33 24 4
gpt4 key购买 nike

我正在研究复杂的网格布局,UltimateGrid 是我的选择。

我设置了多行标题,然后我在垂直标题中加入了一些单元格

现在,我正在寻找一种在我加入的标题单元格中设置多行文本的方法。

这是一个解释性屏幕截图。

explanatory screenshot

我已经尝试过写:

void MyCug::OnSetup(){

int rows = 5;
int cols = 20;

// setup rows and columns
SetNumberRows(rows);
SetNumberCols(cols);

// create 3 row top heading
SetTH_NumberRows(2);

...

JoinCells (16, -2, 16, -1); // Here I joins - in heading - two cells : row 16, columns -2 and -1

...

// Then I retrieve merged cell
CUGCell m_cell;
GetCell(16, -2, &m_cell);

// I need to show multi-line content in heading cells: I tried to set multi-row property.
int result = m_cell.SetPropertyFlags(m_cell.GetPropertyFlags() | UGCELL_MULTIROWCELL);

if (result == UG_SUCCESS) {
bool ok = true; // all seems to be ok...
}

m_cell.SetText("string\r\nstring\r\nstring"); // Despite my attempt, this will be always show on a single line!
SetCell(16, -3, &m_cell);

...
}

没有成功:单元格文本始终显示在一行上,这正是我不想要的。

如何获取多行单元格文本?

最佳答案

我讲述我是如何解决我的问题的,希望它对某人有用。

要设置多行单元格,应使用成员函数CUGCell::SetCellTypeEx()。此函数允许您设置单个单元格的扩展属性。

下面的示例完美运行:

void MyCug::OnSetup(){

int rows = 5;
int cols = 20;

// setup rows and columns
SetNumberRows(rows);
SetNumberCols(cols);

// create 3 row top heading
SetTH_NumberRows(2);

...

JoinCells (16, -2, 16, -1); // Here i joins - in heading - two cells : row 16, columns -2 and -1

...

// I retrieve merged cell
CUGCell m_cell;
GetCell(16, -2, &m_cell);

cell.SetCellTypeEx(UGCT_NORMALMULTILINE); // set multiline cell

m_cell.SetText("string\r\nstring\r\nstring");

SetCell(16, -3, &m_cell);

}

关于c++ - 标题中的多行文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14873173/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com