Remove 5 Row with RowDefinitions.RemoveRange : Grid Operation « Windows Presentation Foundation « VB.Net Tutorial






<Window  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="columndefinitions_grid.Window1"
    Title="ColumnDefinitions Sample">
    <Border BorderBrush="Black" Background="White" BorderThickness="2">
  <DockPanel Margin="10,0,0,0">
    <TextBlock FontSize="20" FontWeight="Bold" DockPanel.Dock="Top">Grid Column and Row Collections</TextBlock>
        <Grid DockPanel.Dock="Top" HorizontalAlignment="Left" Name="grid1" ShowGridLines="true" Width="625" Height="400">
          <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
            <ColumnDefinition/>
          </Grid.ColumnDefinitions>
          <Grid.RowDefinitions>
          <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
          </Grid.RowDefinitions>
        </Grid>

        <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Width="625" DockPanel.Dock="Top">
            <Button Width="125" Click="rem5Row">Remove 5 Rows</Button>  
        </StackPanel>    

  </DockPanel>
  </Border>  
</Window>

//File:Window.xaml.vb

Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents

Namespace columndefinitions_grid
  Public Partial Class Window1
    Inherits Window
    Private rowDef1 As RowDefinition
    Private colDef1 As ColumnDefinition


    Private Sub rem5Row(sender As Object, e As RoutedEventArgs)
      If grid1.RowDefinitions.Count < 5 Then
        Console.WriteLine("less than 5!")
      Else
        grid1.RowDefinitions.RemoveRange(0, 5)
      End If
    End Sub
  End Class
End Namespace








16.35.Grid Operation
16.35.1.Add a ColumnDefinition to GridAdd a ColumnDefinition to Grid
16.35.2.Add a RowDefinition to GridAdd a RowDefinition to Grid
16.35.3.Clear All ColumnsClear All Columns
16.35.4.Clear All RowsClear All Rows
16.35.5.Remove One ColumnRemove One Column
16.35.6.Remove One RowRemove One Row
16.35.7.The current number of ColumnsThe current number of Columns
16.35.8.The current number of RowsThe current number of Rows
16.35.9.Remove 5 Columns with ColumnDefinitions.RemoveRangeRemove 5 Columns with ColumnDefinitions.RemoveRange
16.35.10.Remove 5 Row with RowDefinitions.RemoveRangeRemove 5 Row with RowDefinitions.RemoveRange
16.35.11.Contains RowContains Row
16.35.12.Contains Column?Contains Column?
16.35.13.Insert RowInsert Row
16.35.14.Insert ColumnInsert Column
16.35.15.Set control to specific row and column in codeSet control to specific row and column in code