Skip to content

DevExpress-Examples/asp-net-web-forms-grid-text-wrapping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid Control for ASP.NET Web Forms - Different options for wrapping text

The suggested techniques are common and may be used not only for ASPxGridView, but for other controls also.

Wrapped text

Disable text wrapping to show text in one line

You can disable text wrapping in the following ways:

  • Set a column's CellStyle.Wrap property to false.

    <dx:GridViewDataColumn FieldName="C1" Width="100" Caption='Wrap="False"'>
        <CellStyle Wrap="False" />
    </dx:GridViewDataColumn>
  • Set the CSS white-space property to nowrap.

    .disableWrapping {  
        white-space: nowrap;  
    }
    <dx:GridViewDataColumn FieldName="C2" Width="100" Caption='CSS nowrap'>
        <CellStyle CssClass="disableWrapping" />
    </dx:GridViewDataColumn>

Note that when text wrapping is disabled, the column's Width property in not in effect.

Enable wrapping to set column width

You can enable text wrapping in the following ways:

  • Set the column's CellStyle.Wrap property to true.

    <dx:GridViewDataColumn FieldName="C3" Width="100" Caption='Wrap="True"'>
        <CellStyle Wrap="True" />
    </dx:GridViewDataColumn>
  • Set the CSS white-space property to normal.

    .enableWrapping {  
        white-space: normal;  
    }
    <dx:GridViewDataColumn FieldName="C4" Width="100" Caption='CSS normal'>
        <CellStyle CssClass="enableWrapping" />
    </dx:GridViewDataColumn>

Wrap text without white spaces

The previous approach works if cell text contains white spaces only. To wrap text that does not contain white spaces, use the CSS word-break property.

.wrapEmail {  
    word-break: break-all;  
}
<dx:GridViewDataColumn FieldName="C5" Width="100" Caption='CSS break-all'>
    <CellStyle CssClass="wrapEmail" />
</dx:GridViewDataColumn>

Show a truncated text

Set the GridDataColumnSettings.AllowEllipsisInText property to true to automatically truncate cell text if it does not fit into the cell's width. To indicate clipped text, the control displays an ellipsis ().

<dx:GridViewDataColumn FieldName="C6" Width="100" Caption='Truncated text'>
    <Settings AllowEllipsisInText="true" />
</dx:GridViewDataColumn>

Files to Review

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Try different options to control text wrapping.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •