當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET Grid類代碼示例

本文整理匯總了VB.NET中System.Windows.Controls.Grid的典型用法代碼示例。如果您正苦於以下問題:VB.NET Grid類的具體用法?VB.NET Grid怎麽用?VB.NET Grid使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Grid類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: New

Public Sub New()
    WindowTitle = "Grid Sample"
    'Create a Grid as the root Panel element
    Dim myGrid As New Grid()
    myGrid.Height = 100
    myGrid.Width = 250
    myGrid.ShowGridLines = True
    myGrid.HorizontalAlignment = Windows.HorizontalAlignment.Left
    myGrid.VerticalAlignment = Windows.VerticalAlignment.Top

    ' Define and Add the Rows and Columns
    Dim colDef1 As New ColumnDefinition
    Dim colDef2 As New ColumnDefinition
    Dim colDef3 As New ColumnDefinition
    myGrid.ColumnDefinitions.Add(colDef1)
    myGrid.ColumnDefinitions.Add(colDef2)
    myGrid.ColumnDefinitions.Add(colDef3)

    Dim rowDef1 As New RowDefinition
    Dim rowDef2 As New RowDefinition
    Dim rowDef3 As New RowDefinition
    Dim rowDef4 As New RowDefinition
    myGrid.RowDefinitions.Add(rowDef1)
    myGrid.RowDefinitions.Add(rowDef2)
    myGrid.RowDefinitions.Add(rowDef3)
    myGrid.RowDefinitions.Add(rowDef4)

    Dim txt1 As New TextBlock
    txt1.Text = "2004 Products Shipped"
    txt1.FontSize = 20
    txt1.FontWeight = FontWeights.Bold
    Grid.SetColumnSpan(txt1, 3)
    Grid.SetRow(txt1, 0)
    myGrid.Children.Add(txt1)

    Dim txt2 As New TextBlock
    txt2.Text = "Quarter 1"
    txt2.FontSize = 12
    txt2.FontWeight = FontWeights.Bold
    Grid.SetRow(txt2, 1)
    Grid.SetColumn(txt2, 0)
    myGrid.Children.Add(txt2)

    Dim txt3 As New TextBlock
    txt3.Text = "Quarter 2"
    txt3.FontSize = 12
    txt3.FontWeight = FontWeights.Bold
    Grid.SetRow(txt3, 1)
    Grid.SetColumn(txt3, 1)
    myGrid.Children.Add(txt3)

    Dim txt4 As New TextBlock
    txt4.Text = "Quarter 3"
    txt4.FontSize = 12
    txt4.FontWeight = FontWeights.Bold
    Grid.SetRow(txt4, 1)
    Grid.SetColumn(txt4, 2)
    myGrid.Children.Add(txt4)

    Dim txt5 As New TextBlock
    txt5.Text = "50,000"
    Grid.SetRow(txt5, 2)
    Grid.SetColumn(txt5, 0)
    myGrid.Children.Add(txt5)

    Dim txt6 As New Controls.TextBlock
    txt6.Text = "100,000"
    Grid.SetRow(txt6, 2)
    Grid.SetColumn(txt6, 1)
    myGrid.Children.Add(txt6)

    Dim txt7 As New TextBlock
    txt7.Text = "150,000"
    Grid.SetRow(txt7, 2)
    Grid.SetColumn(txt7, 2)
    myGrid.Children.Add(txt7)

    ' Add the final TextBlock Cell to the Grid
    Dim txt8 As New TextBlock
    txt8.FontSize = 16
    txt8.FontWeight = FontWeights.Bold
    txt8.Text = "Total Units: 300000"
    Grid.SetRow(txt8, 3)
    Grid.SetColumnSpan(txt8, 3)
    myGrid.Children.Add(txt8)

    Me.Content = myGrid
End Sub
開發者ID:VB.NET開發者,項目名稱:System.Windows.Controls,代碼行數:88,代碼來源:Grid


注:本文中的System.Windows.Controls.Grid類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。