disable binding navigator
-
Friday, August 01, 2008 12:51 AM
hello...
i would like to ask how to disable the buttons in BindingNavigator.. below is the code i used in disabling the buttons but whenever i run the program nothing happens..the buttons are still enabled..
Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click
BindingNavigatorMoveFirstItem.Enabled = False
BindingNavigatorDeleteItem.Enabled = False
BindingNavigatorAddNewItem.Enabled = False
BindingNavigatorMoveLastItem.Enabled = False
BindingNavigatorMoveNextItem.Enabled = False
BindingNavigatorMovePreviousItem.Enabled = False
BindingNavigatorPositionItem.Enabled = False
End Sub
All Replies
-
Thursday, August 07, 2008 10:01 AM
bel.lies said:How to disable the buttons on BindingNavigator via BindingNavigatorAddNewItem_Click?
Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click
BindingNavigatorMoveFirstItem.Enabled = False
BindingNavigatorDeleteItem.Enabled = False
BindingNavigatorAddNewItem.Enabled = False
BindingNavigatorMoveLastItem.Enabled = False
BindingNavigatorMoveNextItem.Enabled = False
BindingNavigatorMovePreviousItem.Enabled = False
BindingNavigatorPositionItem.Enabled = False
End Sub
Hi bel.lies,
In those button_Click events on the BindingNavigator, there has been default encapsulated behaviour to set other buttons' Enable property based on BindingNavigatorPosition.
To disable the buttons on BindingNavigator via BindingNavigatorAddNewItem_Click, you can override the default behavior of the AddNewItem button like this:
Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click BindingNavigator1.BeginInvoke(New MethodInvoker(AddressOf DisableItems)) End Sub Private Sub DisableItems() BindingNavigatorMoveFirstItem.Enabled = False BindingNavigatorDeleteItem.Enabled = False BindingNavigatorAddNewItem.Enabled = False BindingNavigatorMoveLastItem.Enabled = False BindingNavigatorMoveNextItem.Enabled = False BindingNavigatorMovePreviousItem.Enabled = False BindingNavigatorPositionItem.Enabled = False End Sub
You also can hide (instead of disabling) the buttons on BindingNavigator via BindingNavigatorAddNewItem_Click via the following two approaches:
Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click BindingNavigatorMoveFirstItem.Visible = False BindingNavigatorDeleteItem.Visible = False BindingNavigatorAddNewItem.Visible = False BindingNavigatorMoveLastItem.Visible = False BindingNavigatorMoveNextItem.Visible = False BindingNavigatorMovePreviousItem.Visible = False BindingNavigatorPositionItem.Visible = False End Sub
Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click Me.BindingNavigator1.AddNewItem.Available = False Me.BindingNavigator1.DeleteItem.Available = False Me.BindingNavigator1.MoveNextItem.Available = False Me.BindingNavigator1.MovePreviousItem.Available = False Me.BindingNavigator1.MoveFirstItem.Available = False Me.BindingNavigator1.MoveLastItem.Available = False Me.BindingNavigator1.PositionItem.Available = False End Sub
Best regards,
Martin Xie- Marked As Answer by Martin Xie - MSFT Thursday, August 07, 2008 10:02 AM
-
Wednesday, August 19, 2009 1:15 PM
Hi Martin Xie,
this is a real good solution. I was searching for this since two days without finding something.
Thank you
Sphinxx- Proposed As Answer by sphinxx Thursday, August 27, 2009 7:25 AM
-
Thursday, August 20, 2009 2:31 AM
Hi Sphinxx,
Glad that the solution could hep you.
By the way, another similar case will be helpful to you too, which demonstrated how to add popup warning message feature when you click Delete icon button on BindingNavigator.http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/e5b8ff08-b2ce-4dfe-a135-14022601d25f/
Thank you for your active participation in MSDN community.
Best regards,
Martin Xie
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback on our support, please contact msdnmg@microsoft.com- Proposed As Answer by sphinxx Thursday, August 27, 2009 7:24 AM

