c# - Get a control from a winfrom inside a tabbar control -


I have a tabbar control and inside the first tab, I have a text box, what do I want when the tab for the first time is selected , The text box will be auto-focused.

I can use the tabbar selected index converted event, but can not access the text box to auto focus. Any ideas?

I am doing this while adding to the tabbar:

  capture = new capture format (photographer name); Capture Tapelevel = false; Capture Visible = true; Capture.formband style = system.window.form.formborder style.No; Capture. Doc = DocStyle. fill; TabControl1.TabPages [0] .Controls.Add (capture); Capture = new capture format (photographer name); Capture Tapelevel = false; Capture Visible = true; Capture.formband style = system.window.form.formborder style.No; Capture. Doc = DocStyle. fill; TabControl1.TabPages [0] .Controls.Add (capture);  

And this is my tab change event:

  Private Zero TabControl1_SelectedIndexChanged (Object Sender, EventArgs e) {switch (tabControl1.SelectedIndex) {case 0: // I want to use textbox here break; Case 1: Break; }}  

The capture format has a textbox called 'ClientCode', I want to create this textbox focus, when a Capture tab is selected.

Did you try with the selected index match event? If you are talking about TabControl , then with the help of the switch case ..

  select selected playback < / Strong> Event> Personal Zero Tab Control 1 Sealed Intext Changed (Object Sender, EventAgds E) {Switch (Sender in TabControl). Selected index) {Case 0: // nothing has to be done .. or you can, if you want .. :) break; Case 1: TBF name Focus (); break; }}  

UPDATE

As you modfied I found out that if you are dynamically adding control to TabPage then given below Dynamically added text box to use snippet

  public form 1 () {InitializeComponent (); Text box TB = new text box (); Tb.Name = "dynamic"; TB Text = "dynamic text"; TabControl1.TabPages [1] .Controls.Add (TB); } Private Zero Tab Control 1 Sealed Intex (Object Sender, Event AGS E) {TabControl TC = (TabControl as Sender); Switch (tc. Selected index) {case: break; Case 1: Control [] temp = tc.tabpages [1]. Controls. Search ("dynamic", true); If (temp.Length == 1) (temp [0]) as a textbox ();) break;}}  

Hope this makes you understand ..!


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -