| | |
How do you focus on text box in tab control on form load?
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: May 2009
Posts: 40
Reputation:
Solved Threads: 0
Hi, i'm trying to focus the cursor on a textbox inside one of my tab controls (3 tabs) but my method doesn't seem to work...Any ideas?
Here is my code:
Here is my code:
C# Syntax (Toggle Plain Text)
private void Maintenance_Load(object sender, EventArgs e) { tabControl1.Focus(); tabControl1.SelectedIndex = 0; txt_CLName.Focus(); }
Hi,
I ran the same code and it focuses fine.
You dont need to call since you then move focus to the textbox.
When you set the SelectedIndex for the tabControl are you selecting the tab page which contains the textbox?
The other thing to do is check that nothing is calling focus away from the textbox after you set focus to it.
I ran the same code and it focuses fine.
You dont need to call
C# Syntax (Toggle Plain Text)
tabControl1.Focus();
When you set the SelectedIndex for the tabControl are you selecting the tab page which contains the textbox?
The other thing to do is check that nothing is calling focus away from the textbox after you set focus to it.
Hello, phoenix_dwarf.
While playing with your code found interesting thingy: it works fine on every tab .. except the 1st one. Anyway, while trying to explain such behaviour, found this:
So, this should work fine:
While playing with your code found interesting thingy: it works fine on every tab .. except the 1st one. Anyway, while trying to explain such behaviour, found this:
•
•
•
•
Originally Posted by MSDN
Note:
Focus is a low-level method intended primarily for custom control authors. Instead, application programmers should use the Select method or the ActiveControl property for child controls, or the Activate method for forms.
c# Syntax (Toggle Plain Text)
tabControl1.SelectedIndex = 0; txt_CLName.Select();
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
![]() |
Similar Threads
- Set the cursor focus on the dynamic text box created (JavaScript / DHTML / AJAX)
- Validation of Masked Text Box? (VB.NET)
- problem with text box....... (C#)
- text1.setfocus problem (Visual Basic 4 / 5 / 6)
- is it possible to passing text box value from one form to another (Visual Basic 4 / 5 / 6)
- How to set the focus on a text box..? (C#)
- How do I show Tab control on my form in Win XP style Look? (VB.NET)
Other Threads in the C# Forum
- Previous Thread: Different character colours in a label (or any other control)?
- Next Thread: is an Enum the right way to go?
| Thread Tools | Search this Thread |
.net access ado.net algorithm alignment array barchart bitmap box broadcast buttons c# chat check checkbox client color combobox control conversion csharp custom customactiondata database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ hospitalmanagementsystems httpwebrequest image index input install java label list listbox listener mandelbrot math mouseclick mysql networking operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





