tags:

views:

37

answers:

2

am using C#, VS-2005

am generate runtime controls like textBox and works it fine but the Indexing problems on it. my code below as follows.

//tbpoint Declare in GlobalArea.

int i=0;

TextBox tb= new TextBox();

tb.Location=tbpoint;

tb.Size=new size(970,60);

tb.Name="Tbox"+i.tostring();

tb.Keypress+=new KeypressEventHandler(tbb_Keypress);

tbpoint+=70;

i++;

this.panel1.Controls.Add(tb);

Above Code call in EnterKeypress Event and works fine but the problem is of Indexing the textboxes generated. The index not increment by 1.

How can I Solve It. Please Help Me.

A: 

If by Index you mean Tab Index, you will need to set that yourself for dynamic controls.

System.Windows.Forms.Control.TabIndex

asawyer
thx sir, for ur feedback, one more question I Have read the URL provided by u. but if i put tabindex on specific runtime control which is increment by new location than it's work or not
mahesh
I'm very sorry but I am having a very hard time understanding what you mean... :(
asawyer
Suppose if I have provided tab index like tb.TabIndex=1 and at runtime it is increment by enterkeypress event as per users' desire it may four textboxes or five not know it's upto user desire. Now if we have to find out that last textbox value is null then setfocus to another contorl like IF tbox04.text="" then textbox2.setfocus which is below of panel1.
mahesh
A: 

The must declare the variable i also in the class body (which you call "global area"). Otherwise, i is reset on every method call to zero.

codymanix
thx sir, it's worksanother question is sir how do i get last index of that controls for put on certain condition or setfocus on another control once again thx for ur feedback
mahesh
SendKeys.Send("{TAB}");
codymanix
thx for ur feedback sir,but when control at runtime and incrment by enterkeypressevent which control has null or not. I wants to put if condition on those runtime control which has null like tbox5.text="" then set focus to textbox2.text
mahesh