Can't Focus more then once.

  • Thread starter Thread starter fatalerror0x00
  • Start date Start date
F

fatalerror0x00

Guest
Hey everyone! I have an annoying issue that I'm hoping you can help me with. I have a TabControl with 6 TabItems. Within the first tab there are a bunch of text boxes. I'd like to give my first text box focus. I have been trying over the last 2 days everything I find and most of what I can think of that is absurdly insane to even do. I had my best luck tonight realizing I totally missed an event supported. Well The event triggers fine and my if statement works but the second time the code runs it doesn't focus. I set a breakpoint for everytime that function runs and it does indeed trigger the if to change focus. I don't understand why it won't take focus after the first time it runs, I change tabs and then change back...Nothing is forcused at all. It's very annoying. Just like I can't get tab indexes to work properly for the life of me. Someone please tell me what is going on.


private void Main_GridR1_TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) {
if(Main_GridR1_TabControl.SelectedIndex == 0) {
Main_GridR1_NASTT_GridC1R3_NewAssetTagM1_TextBox.Focus();
}
}


Everytime Index 0 is pressed and this even triggers it runs as it did the first time yet the 2nd time and on that the if is triggered is does run the .Focus() line but will not actually give focus.


Also strangely enough I decided to be really stupid and tell it to Focus two textboxes. When it ran the first time it focused only to the textbox I told it to focus to first and didn't refocus to the textbox it should have ended with focus to. It's like for some reason you can't Focus more then once per run. If I switched tabs and came back nothing would focus once again like in my original scenario.

Continue reading...
 
Back
Top