Infragistics Grid : How to set two line display in a cell

Sometimes we require to show a two line display in a grid cell. This usually happens when we have columns like OrderNo and Order Code and we want to display both in one cell. It is also a useful practice when we have too many columns and we want to display all the details. So the values can be shown using a line seperator in the cell.

This can be achieved using ” InitializeRow” event. This event is fired for every row. So we can set the details here like this:

Visual Basic .NET Code:

e.row.cells.fromKey(“OrderNo”).Text=e.row.cells.fromKey(“OrderNo”).Text +”
” + e.row.cells.fromKey(“OrderCode”).Text

or
e.row.cells.fromKey(“OrderNo”).Text=e.row.cells.fromKey(“OrderNo”).Text +ControlChars.crlf + e.row.cells.fromKey(“OrderCode”).Text

The fromkey collection can be used or you can also use the cell index to find the appropriate cell. Offcourse, you have to hide OrderCode column in the “InitializeLayout” event.

~Sandeep

Thoughts on Life, Events and Current Happenings

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.