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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top