I'm trying to build a table dynamically where arbitrary cell could potentially span any number of rows/columns.. effectively being able to format a table like below
with each cell (along with label text) represented via the asterisk.
I tried to acheive this via the OriginX, Y and the SpanX, Y properties of each RowLayoutColumnInfo, but the result always seem to disagree with my expectation.
Can someone please provide a simple implementation of the table above? Plus any info on why the final renderings would be different from these settings, will be appreciated.
Looks like the HTML table tags didn't translate.. I'll resort to some ascii art..____|__| || |_|_||_|_|_|
It's ugly.. but basically the first row has a cell that span two colums and a second cell that span 2 rows.
The second row has a cell the span two rows as well, and everything else is 1x1.
Hi,
This seems simple enough. I would use the InitializeLayout event of the grid and do something like this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e){ UltraGridBand band = e.Layout.Bands[0]; band.UseRowLayout = true; band.Columns["Blue"].RowLayoutColumnInfo.OriginX = 0; band.Columns["Blue"].RowLayoutColumnInfo.OriginY = 0; band.Columns["Blue"].RowLayoutColumnInfo.SpanX = 2; band.Columns["Blue"].RowLayoutColumnInfo.SpanY = 1; band.Columns["Red"].RowLayoutColumnInfo.OriginX = 2; band.Columns["Red"].RowLayoutColumnInfo.OriginY = 0; band.Columns["Red"].RowLayoutColumnInfo.SpanX = 1; band.Columns["Red"].RowLayoutColumnInfo.SpanY = 2; band.Columns["Gray"].RowLayoutColumnInfo.OriginX = 0; band.Columns["Gray"].RowLayoutColumnInfo.OriginY = 1; band.Columns["Gray"].RowLayoutColumnInfo.SpanX = 1; band.Columns["Gray"].RowLayoutColumnInfo.SpanY = 2; band.Columns["Green"].RowLayoutColumnInfo.OriginX = 1; band.Columns["Green"].RowLayoutColumnInfo.OriginY = 1; band.Columns["Green"].RowLayoutColumnInfo.SpanX = 1; band.Columns["Green"].RowLayoutColumnInfo.SpanY = 1; band.Columns["White 1"].RowLayoutColumnInfo.OriginX = 1; band.Columns["White 1"].RowLayoutColumnInfo.OriginY = 2; band.Columns["White 1"].RowLayoutColumnInfo.SpanX = 1; band.Columns["White 1"].RowLayoutColumnInfo.SpanY = 1; band.Columns["White 2"].RowLayoutColumnInfo.OriginX = 2; band.Columns["White 2"].RowLayoutColumnInfo.OriginY = 2; band.Columns["White 2"].RowLayoutColumnInfo.SpanX = 1; band.Columns["White 2"].RowLayoutColumnInfo.SpanY = 1;}
I was clear enough in the first post. Basically your example works, but with the label being displayed separately from the cell. Basically it ends up being a table consists of labels, and another table consists of the cell contents.
in my example, there is only one row to the grid, and I want to have the label & cell content displayed next to each other. Except laid out in a table similar to the original example.
My sample code attempts to do this, but it does not look as expected.
oops, I meant "NOT" clear enough.
Well, it sounds like you want the labels to appear with the cells. In other words, the labels are inside the row and are repeated on each row. To do that, you just need to set the RowLayoutLabelStyle to WithCellData.
That's where I'm confused, of course, because the code you posted here does that. Are you saying it's not working? I've never heard of a case where that property simply doesn't work. If you are setting it and it's not working, then my only guess is that something else in your code is setting it back to the default.
Mike,
when the example code executes, it builds the following form
I can only see the cell content of the "Blue" column, while the rest of the columns only have their headers displayed.
Oh, okay, I get it. :)
In my original sample code I was not accounting for the fact that the labels were going to be with the cells in the row. So I assumed that the SpanX and SpanY of each cell would be 1,1.
If you need to fit a label and a cell into the same space, you have to increase the span to account for both.
The easiest thing to do would be to simply double all of the SpanX and SpanY settings.
You might also need to change the LabelSpan in some cases so that the label takes up half the space in the available area - if that's what you want.