vb.net - .NET Tab Control Selected Index - strange behaviour -
i have tab control 7 pages in it. have view model enables 2 buttons backwards , forwards navigation through tab control. working fine, has started behaving strangely, when positioned on tab index 1, , want set tab index 0, selects tab index 3, , displays tab page no controls on it. pressing button other tab page has no problems , pressing forward button, similar. tried 'hard-coding' selected tab, , got same results. code shown below:
public class viewmodel private withevents tabcontrol tabcontrol . . . public sub nexttab() if tabcontrol.selectedindex < tabcontrol.tabcount tabcontrol.selectedindex += 1 end if end sub public sub previoustab() if tabcontrol.selectedindex > 0 ' code in if statement below trying work around problem, none of has been successful if tabcontrol.selectedindex = 1 'tabcontrol.selectedindex = 0 tabcontrol.selectedtab = tabcontrol.tabpages(0) tabcontrol.tabpages(0).focus() else tabcontrol.selectedindex -= 1 end if end if end sub . . . end class dim vm new viewmodel(tcinfotabs) . . . private sub btnnext_click(sender object, e system.eventargs) handles btnnext.click vm.nexttab() end sub private sub btnprevious_click(sender object, e system.eventargs) handles btnprevious.click vm.previoustab() end sub trying move tab index 1 index 0 results in moving index 3. hard coding position in immediate window has same result: tabcontrol.selectedindex = 1 -> ends pointing 3. there no other events in rest of form. if on tab 2 , subtract 1 end on tab 1. if on tab 1 , subtract 1 end on tab 3. working, , stopped. using .net 4.0, suggestions welcome.
found answer: pebkac - problem exists between keyboard , chair. @ bottom of each tab page, had small textbox user tabbed through fields on tab page, automatically move user next tab when entered. field @ bottom of tab order each of tab pages. however, when first tab page selected, enter event field fired, moving next page, same event fire, , same again on next page. happened when moving backwards. no idea why enter event fire field @ end of tab order , if changed tab index under program control. clicking on first tab did not fire enter event field.
short fix - kludge - add flag set buttons each time user moved forward or backward telling field event not fire.
Comments
Post a Comment