jalo Posted August 25, 2005 Posted August 25, 2005 i am trying to clear all the textboxes contained on all tabpages of a tabcontrol, which is enclosed inside a groupbox. what i have is probably very ugly (plus it doesn't work), so please help..... (the line in red wouldn't compile) Dim ctrl As Control Dim ctrl1 As Control Dim tBox As TextBox Dim tBox1 As TextBox Dim tbPage As TabPage For Each ctrl In GroupBox2.Controls If TypeOf ctrl Is TextBox Then tBox = DirectCast(ctrl, TextBox) tBox.Clear() ElseIf ctrl Is TabControl1 Then Dim i As Integer For i = 0 To (Me.TabControl1.TabPages.Count - 1) [color=Red] For Each ctrl1 In Me.TabControl1.TabPages.Item(i)[/color] If TypeOf ctrl1 Is TextBox Then tBox1 = DirectCast(ctrl1, TextBox) tBox.Clear() End If Next Next End If Next Quote
VagabondSW Posted August 25, 2005 Posted August 25, 2005 Me.TabControl1.TabPages.Item(i) is not a collection of Control objects. You may want to try something like this: Dim index As Integer = 0 For Each tab As TabPage In TabControl1.TabPages For Each ctrl As Control In tab.Controls If (TypeOf (ctrl) Is TextBox) Then ctrl.Text = String.Empty End If Next Next Quote "Never ascribe to malice that which can adequately be explained by incompetence." -- Napolean Bonaparte
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.