2013-02-14 78 views
0

我正在研究一个复杂的网格布局,并且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); 

... 
} 

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

如何获得多行上的单元格文本?

+0

\ N'。连续试一试,看看哪一个适合你 – cha 2013-02-15 00:12:28

回答

0

我告诉我如何解决我的问题,希望对某人有用。

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

下面的例子完美地工作:根据控制是如何实施的用于回车/换行代码可以是`\ r \ N`,`\ n \ r`,或`

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

}