Board index » Visual Studio » Disable all text boxes on form at once
|
gshabada
|
|
gshabada
|
Disable all text boxes on form at once
Visual Studio129
how would you disable all text boxes on a form at once/ I thought dim tx as textbox for each tx in me.controls tx.enabled = false next but that crashes, what do you guys suggest? thanks - |
| hirf-spam-me-here
Registered User |
Fri Apr 30 10:20:56 CDT 2004
Re:Disable all text boxes on form at once
* "Brian Henry" <brianiupmsdn@newsgroups.nospam>scripsit:
Quotehow would you disable all text boxes on a form at once/ -- Herfried K. Wagner [MVP] <URL:dotnet.mvps.org/>">dotnet.mvps.org/> - |
| Sven
Registered User |
Fri Apr 30 10:22:24 CDT 2004
Re:Disable all text boxes on form at once
"Brian Henry" <brianiupmsdn@newsgroups.nospam>wrote in message
Quotehow would you disable all text boxes on a form at once/ For Each c In Me.Controls If TypeOf c Is TextBox Then c.Enabled = False End If Next -- Sven Groot - |
| Phill
Registered User |
Fri Apr 30 10:27:29 CDT 2004
Re:Disable all text boxes on form at once
"Brian Henry" <brianiupmsdn@newsgroups.nospam>wrote in message
Quotehow would you disable all text boxes on a form at once/ Otherwise, it will get upset trying to cast, say, a Label into your TextBox variable. Try this (I'm using VB'2003 here) For Each ctl as Control in Me.Controls If ctl Is TextBox Then ctl.Enabled = False End If Next HTH, Phill W. - |
| Cor
Registered User |
Fri Apr 30 10:46:37 CDT 2004
Re:Disable all text boxes on form at once
Hi Brian,
The one I like, I typed it in here so watch typos I hope this helps Cor \\\\ Private sub Set doset(Me) end sub Private Sub doSet(ByVal parentCtr As Control) Dim ctr As Control For Each ctr In parentCtr.Controls if typeof ctr is textbox then ctr.enabled = false end if doSet(ctr) Next End Sub //// - |
| Armin
Registered User |
Fri Apr 30 11:09:11 CDT 2004
Re:Disable all text boxes on form at once
"Brian Henry" <brianiupmsdn@newsgroups.nospam>schrieb
Quotehow would you disable all text boxes on a form at once/ control is assigned to 'tx' that is not a textbox, an InvalidCastException occurs. Instead: dim o as object for each o in me.controls if typeof o is textbox then directcast(o, textbox).enabled = false end if next Note that this only processes the Textboxes directly placed on the Form, not those eg placed on a groupbox on the Form. -- Armin How to quote and why: www.plig.net/nnq/nquote.html">www.plig.net/nnq/nquote.html www.netmeister.org/news/learn2quote.html">www.netmeister.org/news/learn2quote.html - |
| Cor
Registered User |
Fri Apr 30 11:21:50 CDT 2004
Re:Disable all text boxes on form at once
Hi Armin,
QuoteNote that this only processes the Textboxes directly placed on the Form, (It is one of them of course, however this one I like specially in this situation, it is very good when you have to set one handler for all controls) Cor - |
| Brian
Registered User |
Fri Apr 30 11:26:58 CDT 2004
Re:Disable all text boxes on form at once
oh yes, the is.. dumb me forgetting about types
"Sven Groot" <sveng3000@gmx.net>wrote in message Quote"Brian Henry" <brianiupmsdn@newsgroups.nospam>wrote in message - |
| Armin
Registered User |
Fri Apr 30 11:18:08 CDT 2004
Re:Disable all text boxes on form at once
"Armin Zingler" <az.nospam@freenet.de>schrieb
[bla] sorry for sounding like an echo... ;) -- Armin - |
