vb.net - How to disable all buttons inside a TabControl -


i apreciate community, suffering programmer's block , have attempted solve issue in many ways, no avail.

i created demo (mockup) of larger project , have temporarily stored here: demo of issue

what happening: if press exeggcute button buttons 1 thru 4 (in tabpage1 , tabpage2) disabled, , tabpages.

what should happen: if press exeggcute button buttons 1 thru 4 (in tabpage1 , tabpage2) should changed capital letters; however, change should affect buttons , not tabpages titles. buttons being disabled proof of concept; goal make text caps.

this code using:

ctl.text = ucase(ctl.text) - not work, why? need buttons shown in uppercase; however, option disable them works. why?

public class form1     private sub btnexeggcute_click(sender object, e eventargs) handles btnexeggcute.click         dim ctl control         = 0 controls.count - 1             ctl = controls(i)             if typeof ctl tabcontrol                 j = 0 controls.count - 1                     if typeof controls(j) tabcontrol                         ctl.text = ucase(ctl.text) ' not work why? need buttons shown in uppercase; however, disabling them works.                         ctl.enabled = false                     end if                 next j             end if         next     end sub end class 

building on existing approach, need go through each tabcontrol, through each tabpage, , through each button.

you can use for each rather for if you're not doing index. can filter control enumeration on each loop using enumerable.oftype(of tresult) rather typeof t is (as mentioned @plutonix).

' controls tabcontrols each tabcontrol control in controls.oftype(of tabcontrol)     ' controls in each tabcontrol tabpages     each tabpage control in tabcontrol.controls.oftype(of tabpage)         ' controls in each tabpage buttons         each button control in tabpage.controls.oftype(of button)             ' reached button! uppercase it's text             button.text = button.text.toupperinvariant         next     next next 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -