chowchow123
Active member
- Joined
- Sep 6, 2007
- Messages
- 34
- Programming Experience
- 1-3
Hi
I have a form where I want to set the textbox fields to readonly mode by pressing a toolbar button. I've tried the code below - and I get a type cast error 'Unable to cast object of type 'System.Windows.Forms.BindingNavigator' to type 'System.Windows.Forms.TextBoxBase'.' What can I change the Me.Controls to which is causing the problem?
Dim i As TextBoxBase
For Each i In Me.Controls 'iterate through whole form
If TypeOf (i) Is TextBoxBase Then 'if i is a textbox, do nothing
i.ReadOnly = True 'not a button, so enable it for edit
End If
Next
I have a form where I want to set the textbox fields to readonly mode by pressing a toolbar button. I've tried the code below - and I get a type cast error 'Unable to cast object of type 'System.Windows.Forms.BindingNavigator' to type 'System.Windows.Forms.TextBoxBase'.' What can I change the Me.Controls to which is causing the problem?
Dim i As TextBoxBase
For Each i In Me.Controls 'iterate through whole form
If TypeOf (i) Is TextBoxBase Then 'if i is a textbox, do nothing
i.ReadOnly = True 'not a button, so enable it for edit
End If
Next