HtmlTable.Width 속성

정의

HtmlTable 컨트롤의 너비를 가져오거나 설정합니다.

public:
 property System::String ^ Width { System::String ^ get(); void set(System::String ^ value); };
public string Width { get; set; }
member this.Width : string with get, set
Public Property Width As String

속성 값

String

HtmlTable 컨트롤의 너비입니다.

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 Width 속성을 프로그래밍 방식으로의 너비를 제어를 HtmlTable 컨트롤입니다.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void Button_Click(Object sender, EventArgs e)
  {

    // Set the properties of the HtmlTable with the
    // user selections.
    Table1.BgColor = BgColorSelect.Value;
    Table1.Border = Convert.ToInt32(BorderSelect.Value);
    Table1.BorderColor = BorderColorSelect.Value;
    Table1.Height = HeightSelect.Value;
    Table1.Width = WidthSelect.Value;

  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <title>HtmlTable Example</title>
</head>
<body>

   <form id="form1" runat="server">

      <h3>HtmlTable Example</h3>

      <table id="Table1" 
             style="border-width:1; border-color:Black"
             runat="server">

         <tr>
            <th>
               Column 1
            </th>
            <th>
               Column 2
            </th>
            <th>
               Column 3
            </th>
         </tr>
         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
            <td>
               Cell 3
            </td>
         </tr>
         <tr>
            <td>
               Cell 4
            </td>
            <td>
               Cell 5
            </td>
            <td>
               Cell 6
            </td>
         </tr>

      </table>
      
      <hr />

      Select the display settings: <br /><br />

      BgColor:
      <select id="BgColorSelect" 
              runat="server">

         <option value="Red">Red</option>
         <option value="Blue">Blue</option>
         <option value="Green">Green</option>
         <option value="Black">Black</option>
         <option value="White" selected="selected">White</option>
        
      </select>

        

      Border:
      <select id="BorderSelect" 
              runat="server">

         <option value="0">0</option>
         <option value="1" selected="selected">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>

        

      BorderColor:
      <select id="BorderColorSelect" 
              runat="server">

         <option value="Red">Red</option>
         <option value="Blue">Blue</option>
         <option value="Green">Green</option>
         <option value="Black" selected="selected">Black</option>
         <option value="White">White</option>

      </select>

      <br /><br />

      Height:
      <select id="HeightSelect" 
              runat="server">

         <option value="0">0</option>
         <option value="100">100</option>
         <option value="150">150</option>
         <option value="200">200</option>
         <option value="250">250</option>

      </select>

        

      Width:
      <select id="WidthSelect" 
              runat="server">

         <option value="0">0</option>
         <option value="200">200</option>
         <option value="250">250</option>
         <option value="300">300</option>
         <option value="350">350</option>

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

   </form>

</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs)

    ' Set the properties of the HtmlTable with the
    ' user selections.
    Table1.BgColor = BgColorSelect.Value
    Table1.Border = CInt(BorderSelect.Value)
    Table1.BorderColor = BorderColorSelect.Value
    Table1.Height = HeightSelect.Value
    Table1.Width = WidthSelect.Value
    
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <title>HtmlTable Example</title>
</head>
<body>

   <form id="form1" runat="server">

      <h3>HtmlTable Example</h3>

      <table id="Table1" 
             style="border-width:1; border-color:Black"
             runat="server">

         <tr>
            <th>
               Column 1
            </th>
            <th>
               Column 2
            </th>
            <th>
               Column 3
            </th>
         </tr>
         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
            <td>
               Cell 3
            </td>
         </tr>
         <tr>
            <td>
               Cell 4
            </td>
            <td>
               Cell 5
            </td>
            <td>
               Cell 6
            </td>
         </tr>

      </table>
      
      <hr />

      Select the display settings: <br /><br />

      BgColor:
      <select id="BgColorSelect" 
              runat="server">

         <option value="Red">Red</option>
         <option value="Blue">Blue</option>
         <option value="Green">Green</option>
         <option value="Black">Black</option>
         <option value="White" selected="selected">White</option>
        
      </select>

        

      Border:
      <select id="BorderSelect" 
              runat="server">

         <option value="0">0</option>
         <option value="1" selected="selected">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>

        

      BorderColor:
      <select id="BorderColorSelect" 
              runat="server">

         <option value="Red">Red</option>
         <option value="Blue">Blue</option>
         <option value="Green">Green</option>
         <option value="Black" selected="selected">Black</option>
         <option value="White">White</option>

      </select>

      <br /><br />

      Height:
      <select id="HeightSelect" 
              runat="server">

         <option value="0">0</option>
         <option value="100">100</option>
         <option value="150">150</option>
         <option value="200">200</option>
         <option value="250">250</option>

      </select>

        

      Width:
      <select id="WidthSelect" 
              runat="server">

         <option value="0">0</option>
         <option value="200">200</option>
         <option value="250">250</option>
         <option value="300">300</option>
         <option value="350">350</option>

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

   </form>

</body>
</html>

설명

사용 하 여는 Width 속성을 컨트롤의 너비는 HtmlTable 컨트롤입니다. 일반적으로 너비는 픽셀 단위로 지정 됩니다. 그러나 값을 백분율 기호 (%)을 추가 하 여 브라우저 창의 너비의 백분율도 지정할 수 있습니다. 예를 들어 값 100% 브라우저 창의 전체 너비를 나타내는 테이블에 대 한 너비를 나타냅니다. 테이블 자동으로 확장 하 고 계약 사용자는 창 크기를 변경 합니다.

참고

보다 작은 값을 지정 하는 경우의 내용을 표시 하려면 필요 합니다 HtmlTable 컨트롤을이 속성은 무시 됩니다.

적용 대상

추가 정보