473,657 Members | 2,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing dynamically created controls

2 New Member
Hi all,
I am trying to create a VB smart device application.
I create few buttons dynamically on form_load...

something like this:
Dim WithEvents BtnOperate As New OpenNETCF.Windo ws.Forms.Button 2
Me.BtnOperate.L ocation = New System.Drawing. Point(20, 20)
Me.BtnOperate.S ize = New System.Drawing. Size(150, 150)
Me.BtnOperate.T abIndex = 0
Me.Controls.Add (Me.BtnOperate)
Me.BtnOperate.B ackgroundImage = b

then i have a datareceived event in a module, where i receive a command to set focus on one of the buttons (for example left of the one that currently has a button), i tried this trough the property
like this:
Public Property CtrlFocus() As Integer
Get
Dim i As Integer = Me.Controls.Cou nt
Dim ctrl As Control
For Each ctrl In Me.Controls
If ctrl.Focused Then
Return ctrl.TabIndex
End If
Next
End Get
Set(ByVal value As Integer)
Dim ctrl As Control
For Each ctrl In Me.Controls
If ctrl.TabIndex = value Then
ctrl.Focus()
End If
Next
End Set
End Property

with this commands that are in my module...:
dim fm as new frm_main
index = fm.CtrlFocus
frm_main.ctrlfo cus = index +1

but when i try this there is no controls in me.controls in property CtrlFocus!
How could I access dynamically created controls from another thread...or get a list of them...

Hope this is clear whats the problem.
Thanks
Grega
May 8 '07 #1
1 1880
jhreddy
3 New Member
i think you can solve prob



i have used the follwing code in page load event to dynamically generate 5 text boxs.

Dim i As Integer
For i = 1 To 5
Dim txtBox As New TextBox
txtBox.ID = String.Format(" txtBox{0}", i)
Panel1.Controls .Add(txtBox)
Next

now i want to display those entered text in same page when i click on button..
so please help me out... its urgent
May 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
1707
by: Jonathan Williams | last post by:
Hi, I have an object which inherits from WebControl (CUSTOM : WebControl) In this object I have code in which I add child contols: protected override void CreateChildControls() { //this.Controls.Clear(); CustomFieldUtil objCustomFieldUtil = new CustomFieldUtil(); DataTable objDT = objCustomFieldUtil.GetDataTable("custom"); for(intCount = 0; intCount < objDT.Rows.Count; intCount++)
2
2918
by: R Duke | last post by:
I have tried everything I can think of to change the visible property of a design time created control from a dynamically created control's command event handler. Here is the scenario. I have a WebForm with some textboxes, dropdownlists, a panel, imagebutton and so on. When I click on the image button (which was created at design time) I dynamically build a table. In each of row of that new table I put several cells and one cell...
1
2569
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web page dynamically. To do this, First I including a web page (MainPage.aspx) and I made form tag to Runat=Server. I included one table tag and also made this table Runat=Server side. Second I created three Web User Controls e.g. wucCustomerInfo.ascx,
1
3119
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created elements and would like to seek a solution for this. I had looked through several articles for accessing programatically-created dynamic elements such as: 1)
1
1375
by: drakuu | last post by:
All, I created dynamically part of a table and its components such as text boxes etc... As you can see in the example below I created txtAddress textbox... Everything works perfectly until the point where I need to save the textbox input (normally I would use txtAddress.Text). But in my btnContinue_Click class I can't because It's out of the scope. Question: How can I access the dynamically created textboxes and save the inputs?
2
1690
by: omh | last post by:
I started to work on asp.net2.0 just about a month ago. I got a problem which may be minot for the .net Guru's.The problem is I created radiobuttonlist controls dynamically and I could not access the controls in next page after crosspage postback. I am recreating the controls while being postedback in the pageload event. can somebody help me please. I am struggling for the last 1 week.
0
1596
by: Kabo | last post by:
Hi there, I'm currently working on a C# application that deals with dynamically created TabPages based (each TabPage represents a file that has been opened). On each TabPage there is a DataGridView control as well as some other items including a Button whose purpose is to start/stop a timer clock of sorts. The main problem here is that all of my controls are dynamically generated, so if there were 3 TabPages open, there would be 3 different...
1
1943
by: karthik25 | last post by:
Hi, The following code creates a tab container, 5 tab panels, buttons, labels. I was able to add event handlers to the button. But how am i supposed to access the dynamically created labels? For example how do i get the text of the label changed when the corresponding button is clicked? I have given the complete code below. Please help me with this. using System; using System.Collections; using System.Configuration; using System.Data;...
1
4890
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have set text boxes and labels inside the table rows. I then added a button. All of these are done through code. The problem that i am having is i can get the value from a text box with resides inside the first panel (out side of panel that is...
0
8411
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8323
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.