Você está na página 1de 2

6/2/13

vb.net - dynamically add textbox on button click - Stack Overflow

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Tell me more

dynamically add textbox on button click [closed]

I'm working with windows form application in vb.net windows form application in that there are two buttons: 1. Add new Textbox 2. Insert multiple textbox data into database When I click on 1st button it will create new textbox and if I click on 2nd button than it should insert data of multiple textboxes in database. Database has two fields only 1. Id primary key 2. Name And textbox contains name. Please suggest me the way to implement this i have no idea about this.
vb.net textbox

edited Nov 22 '12 at 15:11 Oded 232k 28 254 434

asked Nov 22 '12 at 15:09 javed salat 38 1 10

Is the ID field auto-incremental? Ken - Abdias Software Nov 22 '12 at 15:25 Could you use a different control other than a textbox? Maybe a d a t a g r i d v i e w which you can add rows to and expand dynamically much easier than a group of text boxes. bendataclear Nov 22 '12 at 15:34 yes it's auto-increment. javed salat Nov 22 '12 at 15:34 Is it posiible by datagridview??? javed salat Nov 22 '12 at 15:35

closed as not a real question by Oded , lazyberezovsky, 0x499602D2, Marek Sebera, Graviton Nov 26 '12 at 3:44
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer
In your click-event assuming the ID-field is auto-incrementing in the database: d i mm y T x ta sN e wT e x t B o x m y T x t . N a m e=M e . C o n t r o l s . C o u n t . T o S t r i n g' " r a n d o m "n a m e m y T x t . L o c a t i o n=N e wP o i n t ( 1 0 ,1 0 )' s e tt h ep o s i t i o na c c o r d i n gt oy o u rl a y o u t m y T x t . T a g=" F o rD B "' s o m e t h i n gt oi d e n t i f yi tb y m y T x t . V i s i b l e=T r u e M e . C o n t r o l s . A d d ( m y T x t )' a d di tt of o r m ' sc o n t r o lc o l l e c t i o n . M e . R e f r e s h ' I fi np a n e le t c .c h a n g eM ew i t ht h a tc o n t r o l . Then in your second click event:

stackoverflow.com/questions/13515523/dynamically-add-textbox-on-button-click

1/2

6/2/13

vb.net - dynamically add textbox on button click - Stack Overflow


. . .o p e nd a t a b a s e ,d oc h e c k se t c . F o re a c hcA sC o n t r o li nM e . C o n t r o l s I ft y p e o fcI sT e x t B o xA n d A l s oc . T a g= " F o rD B "T h e n D i mt x tA sS t r i n g=C T y p e ( c ,T e x t B o x ) . T e x t ' i n s e r tt x ti n t od a t a b a s e E n dI f N e x t (A data-grid can do this for you as well).
answered Nov 22 '12 at 15:36 Ken - Abdias Software 4,396 3 17 thank you so much......... javed salat Nov 22 '12 at 15:40 Hey can u post for data-grid-view I did it but data is not inserted into database . javed salat Nov 23 '12 at 10:16

Not the answer you're looking for? Browse other questions tagged vb.net textbox or ask your own question.

stackoverflow.com/questions/13515523/dynamically-add-textbox-on-button-click

2/2

Você também pode gostar