This documentation is archived and is not being maintained.

HtmlTableCell.NoWrap Property

Gets or sets a value indicating whether the text in a cell represented by an instance of the HtmlTableCell class automatically continues on the next line when it reaches the end of the cell.

Namespace: System.Web.UI.HtmlControls
Assembly: System.Web (in system.web.dll)

public bool NoWrap { get; set; }
/** @property */
public boolean get_NoWrap ()

/** @property */
public void set_NoWrap (boolean value)

public function get NoWrap () : boolean

public function set NoWrap (value : boolean)

Property Value

true if the text does not automatically wrap in the cell; otherwise, false. The default value is false.

Use the NoWrap property to specify or determine whether the text in a cell represented by an instance of the HtmlTableCell class automatically continues on the next line when it reaches the end of the cell.

The following code example demonstrates how to use the NoWrap property to programmatically control whether the text wraps in the cells of an HtmlTable control.

<%@ Page Language="C#" AutoEventWireup="True" %>

<script runat="server">

  void Button_Click(Object sender, EventArgs e)
  {

    // Iterate through the rows of the table.
    for (int i = 0; i <= Table1.Rows.Count - 1; i++)
    {

      // Iterate through the cells of a row.
      for (int j = 0; j <= Table1.Rows[i].Cells.Count - 1; j++)
      {
        // Update the properties of each cell. 
        Table1.Rows[i].Cells[j].Align = AlignSelect.Value;
        Table1.Rows[i].Cells[j].NoWrap = Convert.ToBoolean(NoWrapSelect.Value);
        Table1.Rows[i].Cells[j].VAlign = VAlignSelect.Value;
      }

    }

  }

</script>

<html>
<head>
   <title>HtmlTableCell Example</title>
</head>
<body>

   <form runat="server">

      <h3>HtmlTableCell Example</h3>

      <table id="Table1" 
             border="1" 
             bordercolor="black" 
             runat="server">

         <tr>
            <td>
               Here is some content for Cell 1.
            </td>
            <td>
               Here is some content for Cell 2.
            </td>
         </tr>
         <tr>
            <td width="100" height="100">
               Here is some content for Cell 3.
            </td>
            <td width="100" height="100">
               Here is some content for Cell 4.
            </td>
         </tr>

      </table>

      <hr>

      Select the display settings for the cells in the table: <br><br>

      Align:
      <select id="AlignSelect" 
              runat="server">

         <option value="Left" selected>Left</option>
         <option value="Center">Center</option>
         <option value="Right">Right</option>
        
      </select>

      &nbsp;&nbsp;

      NoWrap:
      <select id="NoWrapSelect" 
              runat="server">

         <option value="true">True</option>
         <option value="false" selected>False</option>

      </select>

      &nbsp;&nbsp;

      VAlign:
      <select id="VAlignSelect" 
              runat="server">

         <option value="Top">Top</option>
         <option value="Middle" selected>Middle</option>
         <option value="Bottom">Bottom</option>

      </select>
       
      <br><br>
  
      <input type="button" 
             value="Generate Table"
             onserverclick="Button_Click" 
             runat="server"/>

   </form>

</body>
</html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: