Hello,
I have been trying to conditionally hide a column in a ultrawingrid when the row doesn't have data for that column. As you can see below, the columns with all the a's should be hidden when there is no data. Is it possible to hide the column per row or is it all or nothing? The column does hide if the entire grid doesn't have data for that column but as soon as one row has data, it puts the cell back in the rows that doesn't have data. I check for the values in the InitializeRow procedure. Any help would be appreciated.
What I have:
Col1 Col2 Col3Row1 zzzz zzzz zzzz aaaaaaaaRow2 zzzz zzzz zzzz
Row3 zzzz zzzz zzzz Row4 zzzz zzzz zzzz aaaaaaaa
Col1 Col2 Col3
Row1 zzzz zzzz zzzz aaaaaaaa Row2 zzzz zzzz zzzzRow3 zzzz zzzz zzzz Row4 zzzz zzzz zzzz aaaaaaaa
Hi
It sounds like you are hiding the column instead of the cell. Use the Hidden property on the cell.
I have them both set to hide if it is empty.
Private Sub UltraGrid1_InitializeRow(sender As Object, e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles UltraGrid1.InitializeRow If String.IsNullOrEmpty(e.Row.Cells("LabelNotes").Value.ToString.Replace(" ", "")) = True Then e.Row.Cells("LabelNotes").Column.Hidden = True e.Row.Cells("LabelNotes").Hidden = True Else e.Row.Cells("LabelNotes").Column.Hidden = False e.Row.Cells("LabelNotes").Hidden = False End If End Sub
Like I said before, when there are no rows with "LabelNotes" then it works fine. But as soon as there is at least 1 row with "LabelNotes" then all rows show that cell. It makes my grid look like it has double spacing.
Hi,
Don't hide both. That's not what you want. The Column property is not a sub-object of the cell, it's a backward pointer to the Column object of the band. So when you hide the Column, you are hiding the entire column and all cells of that column.
e.Row.Cells("LabelNotes").Column is exactly the same as grid.DisplayLayout.Bands[0].Columns("LabelNotes"). It's the same column object. So it makes no sense to hide the column based on any value in any particular row.
It sounds like you just want to hide the cell.
You are correct. I do want to hide the cell. It is actually hidden but what I'm trying to achieve here is to have that row shink down. The only time that it shrinks is when the column is hidden. Hiding the cell still makes the grid look like there is an empty row between each row.
example:
There's no way to hide a cell and reclaim the space on a row by row basis.