HtmlTableCell.VAlign Propriedade
Definição
Obtém ou define o alinhamento vertical do conteúdo de uma célula representada por uma instância da classe HtmlTableCell.Gets or sets the vertical alignment for the content of a cell represented by an instance of the HtmlTableCell class.
public:
property System::String ^ VAlign { System::String ^ get(); void set(System::String ^ value); };
public string VAlign { get; set; }
member this.VAlign : string with get, set
Public Property VAlign As String
Valor da propriedade
O alinhamento vertical do conteúdo de uma célula representada por uma instância do HtmlTableCell .The vertical alignment for the content of a cell represented by an instance of HtmlTableCell. O valor padrão é Empty, que indica que essa propriedade não está definida.The default value is Empty, which indicates that this property is not set.
Exemplos
O exemplo de código a seguir demonstra como usar a VAlign propriedade para controlar programaticamente o alinhamento vertical do conteúdo das células em um HtmlTable controle.The following code example demonstrates how to use the VAlign property to programmatically control the vertical alignment of the contents of the cells in an HtmlTable control.
<%@ 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)
{
// 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 xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlTableCell Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HtmlTableCell Example</h3>
<table id="Table1" runat="server"
style="border-width: 1; border-color: Black">
<tr>
<td>
Here is some content for Cell 1.
</td>
<td>
Here is some content for Cell 2.
</td>
</tr>
<tr>
<td style="width:100; height:100">
Here is some content for Cell 3.
</td>
<td style="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="selected">Left</option>
<option value="Center">Center</option>
<option value="Right">Right</option>
</select>
NoWrap:
<select id="NoWrapSelect"
runat="server">
<option value="true">True</option>
<option value="false" selected="selected">False</option>
</select>
VAlign:
<select id="VAlignSelect"
runat="server">
<option value="Top">Top</option>
<option value="Middle" selected="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>
<%@ 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)
Dim i As Integer
Dim j As Integer
' Iterate through the rows of the table.
For i = 0 To Table1.Rows.Count - 1
' Iterate through the cells of a row.
For j = 0 To Table1.Rows(i).Cells.Count - 1
' 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
Next j
Next i
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlTableCell Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HtmlTableCell Example</h3>
<table id="Table1" runat="server"
style="border-width: 1; border-color: Black">
<tr>
<td>
Here is some content for Cell 1.
</td>
<td>
Here is some content for Cell 2.
</td>
</tr>
<tr>
<td style="width:100; height:100">
Here is some content for Cell 3.
</td>
<td style="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="selected">Left</option>
<option value="Center">Center</option>
<option value="Right">Right</option>
</select>
NoWrap:
<select id="NoWrapSelect"
runat="server">
<option value="true">True</option>
<option value="false" selected="selected">False</option>
</select>
VAlign:
<select id="VAlignSelect"
runat="server">
<option value="Top">Top</option>
<option value="Middle" selected="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>
Comentários
Use a VAlign propriedade para especificar o alinhamento vertical do conteúdo em uma célula representada por uma instância da HtmlTableCell classe.Use the VAlign property to specify the vertical alignment of the content in a cell represented by an instance of the HtmlTableCell class.
Observação
Definir essa propriedade afeta apenas a célula representada por uma instância da HtmlTableCell classe.Setting this property affects only the cell represented by an instance of the HtmlTableCell class. Para aplicar o mesmo alinhamento vertical às células de uma linha inteira na tabela, defina a VAlign propriedade da linha representada por uma instância da HtmlTableRow classe.To apply the same vertical alignment to the cells of an entire row in the table, set the VAlign property of the row represented by an instance of the HtmlTableRow class.
A tabela a seguir lista os valores que podem ser usados para essa propriedade.The following table lists the values that can be used for this property.
| ValorValue | DescriçãoDescription |
|---|---|
Top |
Alinha o conteúdo de uma célula com a borda superior da célula.Aligns the contents of a cell with the upper edge of the cell. |
Middle |
Alinha o conteúdo de uma célula no centro da célula.Aligns the contents of a cell in the center of the cell. |
Bottom |
Alinha o conteúdo de uma célula com a borda inferior da célula.Aligns the contents of a cell with the lower edge of the cell. |
Observação
Você também pode usar BaseLine como um valor para essa propriedade.You can also use BaseLine as a value for this property. No entanto, nem todos os navegadores oferecem suporte a esse recurso.However, not all browsers support this feature.