Can't focus TextBox on TabPage
-
Hi, I have small but very annoying problem. My form contain tabcontrol with more tabpages. When I click on separate tabpage I want set focus to first textbox on selected tabpage. Second option for select tabpage is pressing keys from F1 to F8. I tried set textbox as ActiveControl on this form and I tried set focus but it didn't work. I noticed in some cases when I press tab after selecting tabpage focus go to textbox. So I use SendKeys.Send("{Tab}"), but dont't work when I focus tabpage with pressing key. I spent a lot of times to solve problem btu no success. Has anybody solution for my problem? Thanks in advance, Jure
-
Hi, I have small but very annoying problem. My form contain tabcontrol with more tabpages. When I click on separate tabpage I want set focus to first textbox on selected tabpage. Second option for select tabpage is pressing keys from F1 to F8. I tried set textbox as ActiveControl on this form and I tried set focus but it didn't work. I noticed in some cases when I press tab after selecting tabpage focus go to textbox. So I use SendKeys.Send("{Tab}"), but dont't work when I focus tabpage with pressing key. I spent a lot of times to solve problem btu no success. Has anybody solution for my problem? Thanks in advance, Jure
Hi, my first attempt would be to remove all fancy code (SendKeys, ActiveControl, ...) and to set TabStop=true and TabIndex=0 for the control you want to get focus on a tab page. If that is not sufficient, I would use the TabControl.SelectedIndexChanged event Hope this helps. :)
Luc Pattyn [My Articles] [Forum Guidelines]
-
Hi, I have small but very annoying problem. My form contain tabcontrol with more tabpages. When I click on separate tabpage I want set focus to first textbox on selected tabpage. Second option for select tabpage is pressing keys from F1 to F8. I tried set textbox as ActiveControl on this form and I tried set focus but it didn't work. I noticed in some cases when I press tab after selecting tabpage focus go to textbox. So I use SendKeys.Send("{Tab}"), but dont't work when I focus tabpage with pressing key. I spent a lot of times to solve problem btu no success. Has anybody solution for my problem? Thanks in advance, Jure
-
if (this.tabControl1.SelectedTab == this.tabPage1) this.textBox1.Focus(); else if (this.tabControl1.SelectedTab == this.tabPage2) this.textBox3.Focus(); That should do it.
-
Hi, my first attempt would be to remove all fancy code (SendKeys, ActiveControl, ...) and to set TabStop=true and TabIndex=0 for the control you want to get focus on a tab page. If that is not sufficient, I would use the TabControl.SelectedIndexChanged event Hope this helps. :)
Luc Pattyn [My Articles] [Forum Guidelines]
Hi, the use of Sendkeys or ActiveControl was just experiment from despair. I already have set TabStop=true and TabIndex=0. When I run my code with debugger I can see than code where I set focus is called just before show new tabpage. But focus stay in textbox on previous tabpage. Thanks anyway
-
Hi, my first attempt would be to remove all fancy code (SendKeys, ActiveControl, ...) and to set TabStop=true and TabIndex=0 for the control you want to get focus on a tab page. If that is not sufficient, I would use the TabControl.SelectedIndexChanged event Hope this helps. :)
Luc Pattyn [My Articles] [Forum Guidelines]