다음을 통해 공유


방법: RowGroups 속성을 통한 표의 행 그룹 조작

이 예제에서는 RowGroups 속성을 통해 테이블의 행 그룹에서 수행할 수 있는 보다 일반적인 작업 중 몇 가지를 보여 줍니다.

예제

다음 예제에서는 새 테이블을 만들고 Add 메서드를 사용하여 열을 테이블의 RowGroups 컬렉션에 추가합니다.

            Dim tbl As New Table()
            Dim rowGroupsToAdd As Integer = 4
            For x As Integer = 0 To rowGroupsToAdd - 1
                tbl.RowGroups.Add(New TableRowGroup())
            Next x
Table tbl = new Table();
int rowGroupsToAdd = 4;
for (int x = 0; x < rowGroupsToAdd; x++)
    tbl.RowGroups.Add(new TableRowGroup());

다음 예제에서는 새 TableRowGroup을 삽입합니다. 새 열이 인덱스 위치 0에 삽입되어 해당 열은 테이블의 첫 번째 새 행 그룹이 됩니다.

참고참고

TableRowGroupCollection 컬렉션은 0부터 시작하는 표준 인덱스를 사용합니다.

            tbl.RowGroups.Insert(0, New TableRowGroup())
tbl.RowGroups.Insert(0, new TableRowGroup());

다음 예제에서는 테이블의 특정 TableRowGroup(인덱스로 지정)에 여러 행을 추가합니다.

                Dim rowsToAdd As Integer = 10
                For x As Integer = 0 To rowsToAdd - 1
                    tbl.RowGroups(0).Rows.Add(New TableRow())
                Next x
int rowsToAdd = 10;
for (int x = 0; x < rowsToAdd; x++)
    tbl.RowGroups[0].Rows.Add(new TableRow());

다음 예제에서는 테이블의 첫 번째 행 그룹에 있는 행에서 몇 가지 임의의 속성에 액세스합니다.

            ' Alias the working TableRowGroup for ease in referencing.
            Dim trg As TableRowGroup = tbl.RowGroups(0)
            trg.Rows(0).Background = Brushes.CornflowerBlue
            trg.Rows(1).FontSize = 24
            trg.Rows(2).ToolTip = "This row's tooltip"
// Alias the working TableRowGroup for ease in referencing.
TableRowGroup trg = tbl.RowGroups[0];
trg.Rows[0].Background = Brushes.CornflowerBlue;
trg.Rows[1].FontSize = 24;
trg.Rows[2].ToolTip = "This row's tooltip";

다음 예제에서는 테이블의 특정 TableRow(인덱스로 지정)에 여러 셀을 추가합니다.

                Dim cellsToAdd As Integer = 10
                For x As Integer = 0 To cellsToAdd - 1
                    tbl.RowGroups(0).Rows(0).Cells.Add(New TableCell(New Paragraph(New Run("Cell " & (x + 1)))))
                Next x
int cellsToAdd = 10;
for (int x = 0; x < cellsToAdd; x++)
    tbl.RowGroups[0].Rows[0].Cells.Add(new TableCell(new Paragraph(new Run("Cell " + (x + 1)))));

다음 예제에서는 첫 번째 행 그룹의 첫 번째 행에 있는 셀에서 몇 가지 임의의 메서드와 속성에 액세스합니다.

            ' Alias the working for for ease in referencing.
            Dim row As TableRow = tbl.RowGroups(0).Rows(0)
            row.Cells(0).Background = Brushes.PapayaWhip
            row.Cells(1).FontStyle = FontStyles.Italic
            ' This call clears all of the content from this cell.
            row.Cells(2).Blocks.Clear()
// Alias the working for for ease in referencing.
TableRow row = tbl.RowGroups[0].Rows[0];
row.Cells[0].Background = Brushes.PapayaWhip;
row.Cells[1].FontStyle = FontStyles.Italic;
// This call clears all of the content from this cell.
row.Cells[2].Blocks.Clear();

다음 예제에서는 테이블에서 호스팅하는 TableRowGroup 요소의 숫자를 반환합니다.

            Dim rowGroups As Integer = tbl.RowGroups.Count
int rowGroups = tbl.RowGroups.Count;

다음 예제에서는 참조를 사용하여 특정 행 그룹을 제거합니다.

            tbl.RowGroups.Remove(tbl.RowGroups(0))
tbl.RowGroups.Remove(tbl.RowGroups[0]);

다음 예제에서는 인덱스를 사용하여 특정 행 그룹을 제거합니다.

            tbl.RowGroups.RemoveAt(0)
tbl.RowGroups.RemoveAt(0);

다음 예제에서는 테이블의 행 그룹 컬렉션에서 행 그룹을 모두 제거합니다.

            tbl.RowGroups.Clear()
tbl.RowGroups.Clear();

참고 항목

작업

방법: RowGroups 속성을 통한 표의 행 그룹 조작

방법: Blocks 속성을 통한 FlowDocument 조작

방법: Columns 속성을 통해 표의 열 조작