[VB.net] สอบถามเกี่ยวกับการสร้างคอนโทรล BindingNavigator คะ
ต้องการเพิ่มปุ่ม SAVE เข้าไปในคอนโทรล BindingNavigator โดยแสดงเป็นรูปภาพ
แล้วพอรันขึ้นมาแถบคอนโทรล BindingNavigator ไม่ขึ้นน่ะคะ
ไม่ทราบว่าต้องแก้ไขยังไงคะ
ส่วนที่แสดงคะ
โค้ดที่เขียนไว้คะ
Code (VB.NET)
Private Sub btnNewTabpage_Click(sender As Object, e As EventArgs) Handles btnNewTabpage.Click
NewTab(TextBox1.Text)
TextBox1.Clear()
End Sub
Sub NewTab(Optional tabname As String = "New Tab")
Dim bindMandatoryNew As New System.Windows.Forms.BindingNavigator
bindMandatoryNew.Location = New System.Drawing.Point(4, 12)
bindMandatoryNew.Dock = DockStyle.None
bindMandatoryNew.Name = "bindMandatoryNew"
bindMandatoryNew.TabIndex = 4
bindMandatoryNew.Size = New System.Drawing.Size(309, 25)
bindMandatoryNew.AddStandardItems()
Dim bindOptionalNew As New System.Windows.Forms.BindingNavigator
bindOptionalNew.Location = New System.Drawing.Point(4, 246)
bindOptionalNew.Dock = DockStyle.None
bindOptionalNew.Name = "bindOptionalNew"
bindOptionalNew.TabIndex = 6
bindOptionalNew.Size = New System.Drawing.Size(309, 25)
bindOptionalNew.AddStandardItems()
Dim DataGridMandatory As New System.Windows.Forms.DataGridView
DataGridMandatory.Location = New System.Drawing.Point(1, 40)
DataGridMandatory.Size = New System.Drawing.Size(918, 161)
DataGridMandatory.TabIndex = 3
DataGridMandatory.ColumnCount = 5
DataGridMandatory.Columns(0).Name = "ID"
DataGridMandatory.Columns(1).Name = "Name"
DataGridMandatory.Columns(2).Name = "Sub"
DataGridMandatory.Columns(3).Name = "Category"
DataGridMandatory.Columns(4).Name = "Command"
DataGridMandatory.Columns(0).AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
DataGridMandatory.Columns(1).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
DataGridMandatory.Columns(2).AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
DataGridMandatory.Columns(3).AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
DataGridMandatory.Columns(4).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
Dim DataGridOptional As New System.Windows.Forms.DataGridView
DataGridOptional.Location = New System.Drawing.Point(4, 274)
DataGridOptional.Size = New System.Drawing.Size(918, 161)
DataGridOptional.TabIndex = 5
DataGridOptional.ColumnCount = 5
DataGridOptional.Columns(0).Name = "ID"
DataGridOptional.Columns(1).Name = "Name"
DataGridOptional.Columns(2).Name = "Sub"
DataGridOptional.Columns(3).Name = "Category"
DataGridOptional.Columns(4).Name = "Command "
DataGridOptional.Columns(0).AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
DataGridOptional.Columns(1).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
DataGridOptional.Columns(2).AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
DataGridOptional.Columns(3).AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
DataGridOptional.Columns(4).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
Dim tab As New System.Windows.Forms.TabPage
With tab
.Controls.Add(bindMandatoryNew)
.Controls.Add(DataGridMandatory)
.Controls.Add(bindOptionalNew)
.Controls.Add(DataGridOptional)
.Location = New System.Drawing.Point(12, 51)
.Text = tabname
.UseVisualStyleBackColor = True
End With
Me.TabControl1.Controls.Add(tab)
End Sub
Tag : .NET, Ms SQL Server 2008, Win (Windows App), VB.NET
Date :
2015-04-09 16:29:02
By :
AOAOJS
View :
1186
Reply :
1
Items Collection Editor > เพิ่ม ToolStripSeparator, ToolStripButton > Name: SaveButton, DisplayStyle: Image > OK > View Code > สร้าง event handler ให้กับปุ่ม Save
Code (VB.NET)
Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveButton.Click
TableAdapterName.Update(DataSetName.TableName)
End Sub
Date :
2020-06-01 12:01:41
By :
PhrayaDev
Load balance : Server 02