TableCellCollection Třída
Definice
Zapouzdřuje kolekci TableHeaderCell objektů a TableCell , které tvoří řádek v Table ovládacím prvku.Encapsulates a collection of TableHeaderCell and TableCell objects that make up a row in a Table control. Tuto třídu nelze zdědit.This class cannot be inherited.
public ref class TableCellCollection sealed : System::Collections::IList
public sealed class TableCellCollection : System.Collections.IList
type TableCellCollection = class
interface IList
interface ICollection
interface IEnumerable
Public NotInheritable Class TableCellCollection
Implements IList
- Dědičnost
-
TableCellCollection
- Implementuje
Příklady
Následující příklad ukazuje, jak programově vyplnit Table ovládací prvek.The following example demonstrates how to programmatically fill a Table control. TableCell objekty, které představují jednotlivé buňky, jsou přidány do TableRow objektů, které představují jednotlivé řádky prostřednictvím Cells Vlastnosti.TableCell objects, which represent individual cells, are added to TableRow objects, which represent the individual rows, through the Cells property.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
private void Page_Load(Object sender, EventArgs e)
{
// Generate rows and cells.
int numrows = 4;
int numcells = 6;
int counter = 1;
for (int rowNum = 0; rowNum < numrows; rowNum++)
{
TableRow rw = new TableRow();
for (int cellNum = 0; cellNum < numcells; cellNum++)
{
TableCell cel = new TableCell();
cel.Text=counter.ToString();
counter++;
rw.Cells.Add(cel);
}
Table1.Rows.Add(rw);
}
}
private void Button_Click_Coord(object sender, EventArgs e)
{
for (int rowNum = 0; rowNum < Table1.Rows.Count; rowNum++)
{
for (int cellNum = 0; cellNum <
Table1.Rows[rowNum].Cells.Count; cellNum++)
{
Table1.Rows[rowNum].Cells[cellNum].Text =
String.Format("(Row{0}, Cell{1})", rowNum, cellNum);
}
}
}
private void Button_Click_Number(object sender, EventArgs e)
{
int counter = 1;
for (int rowNum = 0; rowNum < Table1.Rows.Count; rowNum++)
{
for (int cellNum = 0; cellNum <
Table1.Rows[rowNum].Cells.Count; cellNum++)
{
Table1.Rows[rowNum].Cells[cellNum].Text =
counter.ToString();
counter++;
}
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>TableCellCollection Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>TableCellCollection Example</h3>
<asp:Table id="Table1"
runat="server"/>
<br />
<center>
<asp:Button id="Button1"
Text="Display Table Coordinates"
OnClick="Button_Click_Coord"
runat="server"/>
<asp:Button id="Button2"
Text="Display Cell Numbers"
OnClick="Button_Click_Number"
runat="server"/>
</center>
</div>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Private Sub Page_Load(sender As Object, e As EventArgs)
' Generate rows and cells.
Dim numrows As Integer = 4
Dim numcells As Integer = 6
Dim counter As Integer = 1
Dim rowNum As Integer
Dim cellNum As Integer
For rowNum = 0 To numrows - 1
Dim rw As New TableRow()
For cellNum = 0 To numcells - 1
Dim cel As New TableCell()
cel.Text = counter.ToString()
counter += 1
rw.Cells.Add(cel)
Next
Table1.Rows.Add(rw)
Next
End Sub
Private Sub Button_Click_Coord(sender As Object, e As EventArgs)
Dim rowNum As Integer
Dim cellNum As Integer
Dim rowCount As Integer
For rowCount = 0 To Table1.Rows.Count - 1
For cellNum = 0 To (Table1.Rows(rowNum).Cells.Count) - 1
Table1.Rows(rowNum).Cells(cellNum).Text = _
String.Format("(Row{0}, Cell{1})", rowNum, cellNum)
Next
Next
End Sub
Private Sub Button_Click_Number(sender As Object, e As EventArgs)
Dim counter As Integer = 1
Dim rowNum As Integer
Dim cellNum As Integer
For rowNum = 0 To Table1.Rows.Count - 1
For cellNum = 0 To (Table1.Rows(rowNum).Cells.Count) - 1
Table1.Rows(rowNum).Cells(cellNum).Text = _
counter.ToString()
counter += 1
Next
Next
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>TableCellCollection Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>TableCellCollection Example</h3>
<asp:Table id="Table1"
runat="server"/>
<br />
<center>
<asp:Button id="Button1"
Text="Display Table Coordinates"
OnClick="Button_Click_Coord"
runat="server"/>
<asp:Button id="Button2"
Text="Display Cell Numbers"
OnClick="Button_Click_Number"
runat="server"/>
</center>
</div>
</form>
</body>
</html>
Poznámky
Pomocí této třídy lze programově spravovat kolekci TableCell objektů, které tvoří řádek v Table ovládacím prvku.Use this class to programmatically manage a collection of TableCell objects that make up a row in a Table control. Tato třída se běžně používá k přidání nebo odebrání buněk z řádku v Table ovládacím prvku.This class is commonly used to add or remove cells from a row in a Table control.
Poznámka
TableOvládací prvek obsahuje Rows kolekci, která představuje kolekci TableRow objektů.A Table control contains a Rows collection that represents a collection of TableRow objects. Každý TableRow představuje jednotlivý řádek v tabulce a obsahuje Cells kolekci, která představuje kolekci TableCell objektů.Each TableRow represents an individual row in the table and contains a Cells collection that represents a collection of TableCell objects. Tyto TableCell objekty reprezentují jednotlivé buňky v tabulce.These TableCell objects represent the individual cells in the table. Chcete-li získat jednotlivou buňku, je nutné nejprve získat TableRow z Rows kolekce Table ovládacího prvku.To get an individual cell, you must first get a TableRow from the Rows collection of a Table control. Pak můžete získat TableCell z Cells kolekce TableRow .You can then get a TableCell from the Cells collection of the TableRow.
Vlastnosti
Count |
Získá počet TableCell objektů v TableCellCollection .Gets the number of TableCell objects in the TableCellCollection. |
IsReadOnly |
Získá hodnotu, která určuje, zda je TableCellCollection určena jen pro čtení.Gets a value indicating whether the TableCellCollection is read-only. |
IsSynchronized |
Načte hodnotu, která označuje, jestli je přístup ke službě TableCellCollection Synchronizovaný (bezpečný pro přístup z více vláken).Gets a value indicating whether access to the TableCellCollection is synchronized (thread-safe). |
Item[Int32] |
Získá TableCell od v TableCellCollection zadaném indexu.Gets a TableCell from the TableCellCollection at the specified index. |
SyncRoot |
Získá objekt, který lze použít k synchronizaci přístupu k TableCellCollection .Gets the object that can be used to synchronize access to the TableCellCollection. |
Metody
Add(TableCell) |
Připojí zadaný TableCell na konec TableCellCollection .Appends the specified TableCell to the end of the TableCellCollection. |
AddAt(Int32, TableCell) |
Přidá zadaný TableCell do v TableCellCollection zadaném umístění indexu.Adds the specified TableCell to the TableCellCollection at the specified index location. |
AddRange(TableCell[]) |
Připojí TableCell objekty ze zadaného pole na konec kolekce.Appends the TableCell objects from the specified array to the end of the collection. |
Clear() |
Odebere všechny TableCell objekty z TableCellCollection .Removes all TableCell objects from the TableCellCollection. |
CopyTo(Array, Int32) |
Zkopíruje položky ze TableCellCollection zadaného Array , počínaje zadaným indexem v Array .Copies the items from the TableCellCollection to the specified Array, starting with the specified index in the Array. |
Equals(Object) |
Určí, zda se zadaný objekt rovná aktuálnímu objektu.Determines whether the specified object is equal to the current object. (Zděděno od Object) |
GetCellIndex(TableCell) |
Vrací hodnotu, která představuje index zadaného TableCell z TableCellCollection .Returns a value that represents the index of the specified TableCell from the TableCellCollection. |
GetEnumerator() |
Vrátí IEnumerator implementovaný objekt, který obsahuje všechny TableCell objekty v TableCellCollection .Returns a IEnumerator implemented object that contains all TableCell objects in the TableCellCollection. |
GetHashCode() |
Slouží jako výchozí funkce hash.Serves as the default hash function. (Zděděno od Object) |
GetType() |
Získá Type aktuální instanci.Gets the Type of the current instance. (Zděděno od Object) |
MemberwiseClone() |
Vytvoří kopii aktuálního seznamu Object .Creates a shallow copy of the current Object. (Zděděno od Object) |
Remove(TableCell) |
Odstraní zadaný TableCell z TableCellCollection .Removes the specified TableCell from the TableCellCollection. |
RemoveAt(Int32) |
Odebere TableCell z v TableCellCollection zadaném indexu.Removes a TableCell from the TableCellCollection at the specified index. |
ToString() |
Vrátí řetězec, který představuje aktuální objekt.Returns a string that represents the current object. (Zděděno od Object) |
Explicitní implementace rozhraní
IList.Add(Object) |
Přidá objekt do kolekce.Adds an object to the collection. |
IList.Contains(Object) |
Určuje, zda je zadaný objekt obsažen v kolekci.Determines whether the specified object is contained within the collection. |
IList.IndexOf(Object) |
Vyhledá zadaný objekt a vrátí index s hodnotou nula prvního výskytu v rámci kolekce.Searches for the specified object and returns the zero-based index of the first occurrence within the collection. |
IList.Insert(Int32, Object) |
Vloží objekt do kolekce v zadaném indexu.Inserts an object into the collection at the specified index. |
IList.IsFixedSize |
Popis tohoto člena naleznete v tématu IsFixedSize .For a description of this member, see IsFixedSize. |
IList.Item[Int32] |
Popis tohoto člena naleznete v tématu Item[Int32] .For a description of this member, see Item[Int32]. |
IList.Remove(Object) |
Odebere objekt z kolekce.Removes an object from the collection. |
Metody rozšíření
Cast<TResult>(IEnumerable) |
Přetypování prvky IEnumerable na zadaný typ.Casts the elements of an IEnumerable to the specified type. |
OfType<TResult>(IEnumerable) |
Filtruje prvky IEnumerable založené na zadaném typu.Filters the elements of an IEnumerable based on a specified type. |
AsParallel(IEnumerable) |
Povoluje paralelní zpracování dotazu.Enables parallelization of a query. |
AsQueryable(IEnumerable) |
Převede IEnumerable na IQueryable .Converts an IEnumerable to an IQueryable. |