Change Textbox Border Style

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

I'm trying to loop through all of the textboxes on my form and change
some of their properties. I'm stuck on changing the border style to
none. Here is my code:

Dim c As Control
For Each c In Me.Controls
If TypeOf c Is TextBox Then
c.Enabled = False
c.BorderStyle = None
End If
Next

It's the "c.BorderStyle = None" line that doesn't work. BorderStyle
isn't an option in this context and I can't figure out how to do
this. Any ideas?

Thanks
Randy
 
I'm trying to loop through all of the textboxes on my form and change
some of their properties. I'm stuck on changing the border style to
none. Here is my code:

Dim c As Control
For Each c In Me.Controls
If TypeOf c Is TextBox Then
c.Enabled = False
c.BorderStyle = None
End If
Next

It's the "c.BorderStyle = None" line that doesn't work. BorderStyle
isn't an option in this context and I can't figure out how to do
this. Any ideas?

Thanks
Randy
Dim c As Control
For Each c In Me.Controls
If TypeOf c Is TextBox Then
c.Enabled = False
c.BorderStyle = None
End If
Next

Cast the control into a textbox first, something like:

Dim c As Control
For Each c In Me.Controls
If TypeOf c Is TextBox Then
Dim tb as TextBox = DirectCast(c, TextBox)
tb.Enabled = False
tb.BorderStyle = None
End If
Next

Thanks,

Seth Rowe
 
Back
Top