I have bound a dataview to some controls (textbox, rtf, etc...) and some records need to be read only based on some of my own logic... now, whenever the position changes, I can determine if the row can be edited, but I need to block editing in the UI as well. My first thought was to toggle the "AllowEdit" property of the DataView, but that doesn't seem to have any effect on my bound controls. I had only used AllowEdit with DataGrids in the past, so I am not sure if it is even supposed to have an effect in other binding situations.
Now, I could easily go through the bound controls and set ReadOnly = True, but I was hoping for a more centralized method that wouldn't involve changes whenever I added a new bound control.
Thoughts Advice

Selectively making bound controls Read Only
Piocon
If you do this in the Format event, you'll want to make sure to declare your Binding, then add the event handler, then add the binding (if you add the binding directly, you'll miss the first Format event). The other drawback is that you'll have to add handlers to all the bindings where you want to control the readonly-ness.
The advantage of using the Format event, though, is that it's more flexible: if you have controls that are going to be bound to a certain field, then bound to something different, then not bound at all, you don't have to keep track of it: your bindings can do it for you.
-Scott
J.R. Odden
le_sloth
R Phillips
Good luck! :)
gofrm
One thought I have off the top of my head is to setup a Method to handle the BindingManagerBase.PositionChanged, then in that Method check to see if the current row is readonly or not and then loop through BindingManagerBase.Bindings and change the ReadOnly or Enabled Properties accordingly for all the controls (it's unfortunate they don't all have ReadOnly Properties like the TextBox does...a bunch of us on here have actually requested this a few times here on the forum wishlist)
So maybe something like this Method would work...
Private Sub MyBindingManager_PositionChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim Enabled As Boolean = MyVariableThatSaysIfIShouldBeAbleToEditTheControls
For Each CurBinding As Binding In MyBindingManager.Bindings
If TypeOf CurBinding.Control Is TextBox Then
DirectCast(CurBinding.Control, TextBox).ReadOnly = Enabled
Else
CurBinding.Control.Enabled = Enabled
End If
Next
End Sub
just pseudo code and an idea...haven't actually tried it.