本文整理匯總了VB.NET中System.Windows.Forms.DataGridView.BorderStyle屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET DataGridView.BorderStyle屬性的具體用法?VB.NET DataGridView.BorderStyle怎麽用?VB.NET DataGridView.BorderStyle使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Windows.Forms.DataGridView
的用法示例。
在下文中一共展示了DataGridView.BorderStyle屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Form1
' 導入命名空間
Imports System.Data
Imports System.Data.SqlClient
Imports System.Windows.Forms
Imports System.Drawing
Public Class Form1
Inherits System.Windows.Forms.Form
Private WithEvents dataGridView1 As New DataGridView()
Private bindingSource1 As New BindingSource()
Public Sub New()
Me.dataGridView1.Dock = DockStyle.Fill
Me.Controls.Add(Me.dataGridView1)
InitializeDataGridView()
End Sub
Private Sub InitializeDataGridView()
Try
' Set up the DataGridView.
With Me.dataGridView1
' Automatically generate the DataGridView columns.
.AutoGenerateColumns = True
' Set up the data source.
bindingSource1.DataSource = GetData("Select * From Products")
.DataSource = bindingSource1
' Automatically resize the visible rows.
.AutoSizeRowsMode = _
DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders
' Set the DataGridView control's border.
.BorderStyle = BorderStyle.Fixed3D
' Put the cells in edit mode when user enters them.
.EditMode = DataGridViewEditMode.EditOnEnter
End With
Catch ex As SqlException
MessageBox.Show("To run this sample replace " _
& "connection.ConnectionString with a valid connection string" _
& " to a Northwind database accessible to your system.", _
"ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
System.Threading.Thread.CurrentThread.Abort()
End Try
End Sub
Private Shared Function GetData(ByVal sqlCommand As String) _
As DataTable
Dim connectionString As String = _
"Integrated Security=SSPI;Persist Security Info=False;" _
& "Initial Catalog=Northwind;Data Source=localhost"
Dim northwindConnection As SqlConnection = _
New SqlConnection(connectionString)
Dim command As New SqlCommand(sqlCommand, northwindConnection)
Dim adapter As SqlDataAdapter = New SqlDataAdapter()
adapter.SelectCommand = command
Dim table As New DataTable
table.Locale = System.Globalization.CultureInfo.InvariantCulture
adapter.Fill(table)
Return table
End Function
<STAThreadAttribute()> _
Public Shared Sub Main()
Application.Run(New Form1)
End Sub
End Class