Hi everybody,
Greetings from Brazil. I'm new to C# and would really appreciate it if anyone could please help me translate the VB2005 code below to C#. The following code locks all TextBox and MaskedTextBox controls on a form. Thanks in advance.
Best regards,
JC
Public Sub LockForm()
On Error Resume Next
Dim ctl As Control
For Each ctl In Me.Controls
If CType(ctl, TextBox).ReadOnly = False And CType(ctl, MaskedTextBox).ReadOnly = False Then
CType(ctl, TextBox).ReadOnly = True
CType(ctl, TextBox).BackColor = Color.White
CType(ctl, MaskedTextBox).ReadOnly = True
CType(ctl, MaskedTextBox).BackColor = Color.White
End If
Next
End Sub
Greetings from Brazil. I'm new to C# and would really appreciate it if anyone could please help me translate the VB2005 code below to C#. The following code locks all TextBox and MaskedTextBox controls on a form. Thanks in advance.
Best regards,
JC
Public Sub LockForm()
On Error Resume Next
Dim ctl As Control
For Each ctl In Me.Controls
If CType(ctl, TextBox).ReadOnly = False And CType(ctl, MaskedTextBox).ReadOnly = False Then
CType(ctl, TextBox).ReadOnly = True
CType(ctl, TextBox).BackColor = Color.White
CType(ctl, MaskedTextBox).ReadOnly = True
CType(ctl, MaskedTextBox).BackColor = Color.White
End If
Next
End Sub