<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim DataGridViewCellStyle2 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
Me.DataGridView1 = New System.Windows.Forms.DataGridView()
Me.Column1 = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.Column2 = New System.Windows.Forms.DataGridViewComboBoxColumn()
Me.Column3 = New System.Windows.Forms.DataGridViewComboBoxColumn()
Me.Column4 = New System.Windows.Forms.DataGridViewButtonColumn()
CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'DataGridView1
'
Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
Me.DataGridView1.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.Column1, Me.Column2, Me.Column3, Me.Column4})
Me.DataGridView1.Location = New System.Drawing.Point(43, 53)
Me.DataGridView1.Name = "DataGridView1"
Me.DataGridView1.Size = New System.Drawing.Size(431, 272)
Me.DataGridView1.TabIndex = 0
'
'Column1
'
Me.Column1.HeaderText = "IP/DNS"
Me.Column1.Name = "Column1"
'
'Column2
'
Me.Column2.HeaderText = "Port"
Me.Column2.Items.AddRange(New Object() {"1001", "1002", "1003", "1004", "1005", "1006"})
Me.Column2.Name = "Column2"
Me.Column2.Resizable = System.Windows.Forms.DataGridViewTriState.[True]
Me.Column2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic
'
'Column3
'
Me.Column3.HeaderText = "Status"
Me.Column3.Items.AddRange(New Object() {"เชื่อมต่อ", "ไม่เชื่อมต่อ"})
Me.Column3.Name = "Column3"
'
'Column4
'
DataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter
DataGridViewCellStyle2.NullValue = "Delete"
Me.Column4.DefaultCellStyle = DataGridViewCellStyle2
Me.Column4.HeaderText = "Delete"
Me.Column4.Name = "Column4"
Me.Column4.Resizable = System.Windows.Forms.DataGridViewTriState.[True]
Me.Column4.Width = 60
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(852, 417)
Me.Controls.Add(Me.DataGridView1)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Friend WithEvents DataGridView1 As System.Windows.Forms.DataGridView
Friend WithEvents Column1 As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents Column2 As System.Windows.Forms.DataGridViewComboBoxColumn
Friend WithEvents Column3 As System.Windows.Forms.DataGridViewComboBoxColumn
Friend WithEvents Column4 As System.Windows.Forms.DataGridViewButtonColumn
End Class
Code (VB.NET)
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class
ปล.แนะนำให้สร้าง form ใหม่ แล้วก๊อบ โค้ดเข้าไป ครับ จะได้ไม่มีผลกับ form เก่าเรา
Private Sub DataGridView1_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseClick
If e.ColumnIndex = 3 Then
If MessageBox.Show("มั่นใจนะว่าจะลบ", "เตือนวาระสุดท้าย", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
DataGridView1.Rows.RemoveAt(e.RowIndex)
End If
End If
End Sub
Private Sub DataGridView1_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseClick
If e.ColumnIndex = 3 Then
If MessageBox.Show("มั่นใจนะว่าจะลบ", "เตือนวาระสุดท้าย", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
DataGridView1.Rows.RemoveAt(e.RowIndex)
End If
Else If e.ColumnIndex = 2 Then
If DataGridView1(2,e.RowIndex).Value = "เชื่อมต่อ" then
'เชื่อมต่อ
Else DataGridView1(2,e.RowIndex).Value = "ไม่เชื่อมต่อ" Then
'ยกเลิกการเชื่อมต่อ
Else
MessageBox.Show("เกิดข้อผิดพลาด", "ผิดพลาด")
End If
End If
End Sub