how to insert a value into text box

Posted by Vforvijay under VB.NET on 3/9/2011 | Points: 10 | Views : 3711 | Status : [Member] | Replies : 2
hi..in vb.net i have two form In form i have number of textbox,Now i need to open the form2 from form1 and also i want to populate the data to the textbox from the form1,i kept textbox name as txtname1,txtname1.......txtname15

In form 1 using for loop i try to insert the data to textbox..my code is likethis
.form2
.txtname&i=""
i knew its not correct sp plz help me to insert into textbox bu using forloop




Responses

Posted by: T.saravanan on: 3/9/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Refer this code its give some idea to you...
Consider, if you using DataTable for looping...
Its in C#... Kindly change into VB..
for(int x=0; x < dtData.Rows.Count; x++)

{
string sControl = "txtname"+(x+1);
Control[ ] cntObj = this.Control.Find(sControl, true)
if(cntObj.Length > 0)
{
Control cntText = cntObj[0];
cntText.Text = dtData.Rows[x][0].ToString();
}
}


Try this...

Note: Pass the DataTable value into Fom2 using Constructor.

Cheers :)



Thanks,
T.Saravanan

Vforvijay, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 3/10/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

You can create an intermediate to save the values in a MODULE and try to use it across the forms.

Thanks
Karthik
www.f5Debug.net

Vforvijay, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response