C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






To Create Dynamic Text Box


Posted Date: 08 Aug 2008    Resource Type: Code Snippets    Category: Winforms Controls
Author: D.Jeya kumar(JK)Member Level: Diamond    
Rating: Points: 7



To create dynamic text box or any other control. use the below code sample. Add a text box(To get the input for creating dynamic text box), a flowlayout to add the dynamic controls, a button to create dynamic controls.


'Declaration
Dim Txtdynamic As TextBox
Dim intcount As Integer
Dim inttxtcnt As Integer

Add the below

Try

'to check the textbox for empty
If Not TextBox1.Text Is String.Empty Then
inttxtcnt = TextBox1.Text
Else
Exit Sub
End If

'To create the dynamic text box and add the controls to Flowlayout panel
For intcount = 0 To inttxtcnt - 1
Txtdynamic = New TextBox
Txtdynamic.AutoSize = True

'set the font size
Txtdynamic.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Txtdynamic.Name = "txtdynamic_" & intcount & "_mycntrl"
FlowLayoutPanel1.Controls.Add(Txtdynamic)
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try


'To get the values from dynamic created values

Dim intdyncnt As Integer
'to check the textbox for empty
If Not TextBox1.Text Is String.Empty Then
inttxtcnt = TextBox1.Text
Else
Exit Sub
End If

Try

'To get the dynamic text box values which is added in flowlayout panel
For intcount = 0 To inttxtcnt - 1
If Not TextBox1.Text Is String.Empty Then
If FlowLayoutPanel1.Controls(intcount).Name = "txtdynamic_" & intcount & "_mycntrl" Then
If CInt(Txtdynamic.Text) > 0 Then
intdyncnt += CInt(FlowLayoutPanel1.Controls(intcount).Text)
End If
End If
End If
Next
MsgBox(" The sum of the values is " & intdyncnt)
Catch ex As Exception
MsgBox(ex.Message)
End Try




Responses

Author: D.Jeya kumar(JK)    08 Aug 2008Member Level: Diamond   Points : 0
hi,


good post keep doing it thanks

regards
JK


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
To Create Dynamic Text Box  .  Dynamically create textbox  .  Creating texbox dynamically  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Trasferring Values From One Form to another
Previous Resource: Progress bar sample in VB.net windows Application
Return to Discussion Resource Index
Post New Resource
Category: Winforms Controls


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use