forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAllowAdd.vb
42 lines (35 loc) · 1.64 KB
/
AllowAdd.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Public Class AllowAdd
Private Sub ProductsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductsBindingNavigatorSaveItem.Click
Me.Validate()
Me.ProductsBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.NorthwndDataSet)
End Sub
Private Sub AllowAdd_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'NorthwndDataSet.Products' table. You can move, or remove it, as needed.
Me.ProductsTableAdapter.Fill(Me.NorthwndDataSet.Products)
End Sub
' <Snippet1>
Private Sub DataRepeater1_AllowUserToAddItemsChanged(
) Handles DataRepeater1.AllowUserToAddItemsChanged
' If this event occurs during form initialization, exit.
If Me.IsHandleCreated = False Then Exit Sub
' If AllowUserToAddItems is False.
If DataRepeater1.AllowUserToAddItems = False Then
' Disable the Add button.
BindingNavigatorAddNewItem.Enabled = False
' Disable the BindingSource property.
ProductsBindingSource.AllowNew = False
Else
' Otherwise, enable the Add button.
BindingNavigatorAddNewItem.Enabled = True
End If
End Sub
' </Snippet1>
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If DataRepeater1.AllowUserToAddItems = False Then
DataRepeater1.AllowUserToAddItems = True
Else
DataRepeater1.AllowUserToAddItems = False
End If
End Sub
End Class