Hi,
I rarely ask questions, but I have been struggling with this for several hours, and I am sure you can help me.
I am using a simple RowLayout with 3 fields in the first line (OriginY = 0), except a "Comments" field which is on the second line (OriginY = 1) and spans 3 fields.
What I would like is for the comments line to only show when actual comments exist.
So I am trying to make the second line to be 0 or 1 pixels in height as the minimum by setting the preferredcellsize of the Comments cell to (1,1).
But it still displays the full height Comments line even when no text is in it.
What would be property or properties I need to set to make this happen?
Thank you for posting in our forums.
If the cell you want to hide is at the bottom of the row, you can use the InitializeRow event to hide the cell. First you will need to set the MinRowHeight property to 1 and then the RowSizing property to Free. This will allow to set the row height to whatever positive number you want and each row can have its own height. After that in the initialize row event if the comment cell has no value, reduce the Height of the row so that only the top level cells are displayed.
I have attached a sample which demonstrates this suggestion.
Please let me know if you have any additional questions.
Thanks. Your solution pointed me in the right direction.
Yours did not fully work in my case because
1) The height of the cells in the first line of the layout can grow when those cells have a lot of text in them. So dividing the row height by 2 is not valid anymore.
2) In addition, the InitializeRow event does not work for me because InitializeRow gets triggered BEFORE the row layout has been finalized.
So instead I just loop through the rows after setting the DataSource, and use the GetCellSizeResolved function (the cell Height property does not give the correct value) like so:
' Resize row height to hide empty comment lines For Each R As Infragistics.Win.UltraWinGrid.UltraGridRow In Me.UltraGrid1.Rows.GetRowEnumerator(Infragistics.Win.UltraWinGrid.GridRowType.DataRow, Nothing, Nothing) If R.IsDataRow Then If R.Cells("Comment1").Tag = "NOCOMMENT" Then
R.Height = R.GetCellSizeResolved(Me.UltraGrid1.DisplayLayout.Bands(0).Columns("Value1")).Height
End If
Next
(Value1 is just one of the fields in the first line of the layout, and Comment1 is the field on the second line of the layout)
Thanks!
I am glad that you have resolved your issue. Do not hesitate to contact us if you have any additional questions.
Thank you for using Infragistics.