Visual Basic.NET - For Each vObj In oFormulario.Controls ???

 
Vista:

For Each vObj In oFormulario.Controls ???

Publicado por Francizko (1 intervención) el 15/11/2008 00:04:11
una preguns en Vb 6.0 ago esto para limpiar los controles que tengo

Public Sub GS_Nuevo(oFormulario As Form)
Dim vObj As Object
Dim v As MaskEdBox
On Error GoTo errHandler
For Each vObj In oFormulario.Controls
If TypeOf vObj Is TextBox Then vObj.Text = Empty: vObj.Tag = Empty
If TypeOf vObj Is txtNumero Then vObj.Text = "0.00": vObj.Tag = Empty
If TypeOf vObj Is txtFecha Then vObj.Text = "": vObj.Tag = Empty
' If TypeOf vObj Is SSTab Then vObj.Tab = 0: vObj.Tag = Empty
If TypeOf vObj Is MaskEdBox Then vObj.Text = Empty: vObj.Tag = Empty
If TypeOf vObj Is CheckBox Then vObj.Value = 0
If TypeOf vObj Is OptionButton Then vObj.Value = False
If TypeOf vObj Is TDBCombo Then vObj.BoundText = Empty: vObj.Text = Empty
If TypeOf vObj Is ComboBox And (vObj.Name <> "cbOrdenado" And vObj.Name <> "cboEstado" And vObj.Name <> "cbOpcionBusca") Then vObj.ListIndex = -1
If TypeOf vObj Is MSHFlexGrid Then vObj.Clear: vObj.Tag = Empty
Next
Set vObj = Nothing
Exit Sub
errHandler:
GS_MensajeError err.Description, err.Number, err.Source
End Sub

En VB. Net 2005 como ago lo mismo a lo unico que llegue es a esto

Public Sub GS_Nuevo(ByRef oFormulario As Panel)
Try
For Each vObj As Control In oFormulario.Controls
If TypeOf vObj Is TextBox Then vObj.Text = Nothing : vObj.Tag = Nothing
If TypeOf vObj Is CheckBox Then vObj.Tag = Nothing
If TypeOf vObj Is RadioButton Then vObj.Tag = Nothing
'If TypeOf vObj Is ComboBox And (vObj.Name <> "cbOrdenado" And vObj.Name <> "cboEstado" And vObj.Name <> "cbOpcionBusca") Then vObj.SelectedIndex = -1
Next


Catch ex As Exception
GS_Mensaje(ex.Message, ex.GetHashCode, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

End Sub

* Mas q todo mi pregunta es con los CheckBox y RadioButton , ya q no me acepta la propiedad CheckBox1 ??? q solucion me pueden dar si quiero desmarcar ambos controles ya q en mi formulario son varios y esta es una funcion publica q es accedidad por varios formulario ????
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder