Does anyone know if you can or how u can get a collection of controls that are bound to your BindingSource. I want to be able to dynamically enable or disable the collection of controls based on whether my user is in edit mode or not.
[COLOR=yellowgreen]'added a edit toolstripbutton to the bindingnavigator[/COLOR]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] EditButton_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] btnCancel.Click
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] tsb [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] ToolStripButton
tsb = sender
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] bn [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] BindingNavigator = tsb.GetCurrentParent()
bn.BindingSource. [COLOR=yellowgreen]'At this point i have the binding source for the navigator and i want to set the enable/disable modes to each control binded to the source.[/COLOR]
[COLOR=yellowgreen]' i think i can use your solution here[/COLOR][SIZE=2][COLOR=#0000ff]
For[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] ctr [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Control [/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=black]tsb.Owner.Parent.Controls [/COLOR][COLOR=yellowgreen]'me.controls[/COLOR]
[/SIZE][/COLOR][/SIZE][SIZE=2]MsgBox(ctr.Name)
[SIZE=2][COLOR=#0000ff][COLOR=yellowgreen]'determine here if bound to bn.BindingSource and set mode[/COLOR]
Next
[/COLOR][/SIZE][/SIZE]
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
Private Sub BindingNavigatorEditItem_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles BindingNavigatorEditItem.Click
Dim button As ToolStripButton = DirectCast(sender, ToolStripButton)
Dim navigator As BindingNavigator = DirectCast(button.GetCurrentParent(), BindingNavigator)
'Enable all bound controls for editing.
For Each binding As Binding In navigator.BindingSource.CurrencyManager.Bindings
binding.Control.Enabled = True
Next binding
End Sub