I'm working on a complex grid layout, and UltimateGrid is my choice.
I have set a multi-row heading, then I have joined some cells in heading vertically.
Now, I'm looking for a way to set multi-line text in heading cells which I have joined.
Here's an explanatory screenshot.
I already have tried by writing:
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);
...
}
Without success: cell text is always shown on a single line, that is exactly what I don't want.
How can I get the cell text on multiple lines?
I tell how I have solved my problem, hoping it will be useful to someone.
To set multi-line cells, member function CUGCell::SetCellTypeEx() should be used. This function allow you to set extended properties for single cells.
The example below works perfectly:
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);
}