473,396 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to add a new control within a do while

Rob
I am doing something wrong....

I am trying to add a user defined control to a FlowLayoutPanel for each row
read in a do while loop...

What is happening is that only one control is getting added, not one for
each row.

' declare user defined variable
Dim aUser as New UserDefined1

'declare Flow Layout panel variable
Dim FLP as New FlowLayoutPanel

' Add the Flowlayoutpanel to the form
frm.controls.Add(FLP)

' set some properties of the FLP...
blah blah

' set up stored proc
blah blah
Do While dr.Read()

'This loop is working correctly because I have a msgbox report the
primary key

FLP.Controls.Add(aUser)

Loop
Any ideas ?


May 25 '07 #1
2 1238
Move the definition of the control inside the loop. For Example:

Do While dr.Read()

Dim aUser as New UserDefined1

FLP.Controls.Add(aUser)

Loop

You may also want to wire up some event handlers at the time you add the
control also.

"Rob" <ro***@yahoo.comwrote in message
news:PM******************************@comcast.com. ..
>I am doing something wrong....

I am trying to add a user defined control to a FlowLayoutPanel for each
row read in a do while loop...

What is happening is that only one control is getting added, not one for
each row.

' declare user defined variable
Dim aUser as New UserDefined1

'declare Flow Layout panel variable
Dim FLP as New FlowLayoutPanel

' Add the Flowlayoutpanel to the form
frm.controls.Add(FLP)

' set some properties of the FLP...
blah blah

' set up stored proc
blah blah
Do While dr.Read()

'This loop is working correctly because I have a msgbox report the
primary key

FLP.Controls.Add(aUser)

Loop
Any ideas ?


May 25 '07 #2
Rob
Thanks Ray, works well now !

"Ray Cassick" <rc******@enterprocity.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Move the definition of the control inside the loop. For Example:

Do While dr.Read()

Dim aUser as New UserDefined1

FLP.Controls.Add(aUser)

Loop

You may also want to wire up some event handlers at the time you add the
control also.

"Rob" <ro***@yahoo.comwrote in message
news:PM******************************@comcast.com. ..
>>I am doing something wrong....

I am trying to add a user defined control to a FlowLayoutPanel for each
row read in a do while loop...

What is happening is that only one control is getting added, not one for
each row.

' declare user defined variable
Dim aUser as New UserDefined1

'declare Flow Layout panel variable
Dim FLP as New FlowLayoutPanel

' Add the Flowlayoutpanel to the form
frm.controls.Add(FLP)

' set some properties of the FLP...
blah blah

' set up stored proc
blah blah
Do While dr.Read()

'This loop is working correctly because I have a msgbox report the
primary key

FLP.Controls.Add(aUser)

Loop
Any ideas ?



May 25 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Craig | last post by:
I'm trying to do this within a control I've created: Cursor.Current = Cursors.WaitCursor; During the initialization of the parent form, my control gets added to the form, and while the control...
1
by: bill yeager | last post by:
I have a datagrid control within a datalist control. When I try and do a "Find" on the control, the object comes back with nothing and then my pgm crashes. I am 100% sure that my datagird inside...
7
by: Buck Rogers | last post by:
Hi all! Newbie here. Below is an example from Teach Yourself C in 21 Days. My apologies if it is a bit long. What I don't understand is how the "get_data" function can call the...
8
by: Rob | last post by:
Is it possible for a control to raise an event to remove itself ? Specifically... I have a FlowLayoutPanel that contains several instances of the same user control. Within each "user"...
0
by: ChopStickr | last post by:
I have a custom control that is embedded (using the object tag) in an html document. The control takes a path to a local client ini file. Reads the file. Executes the program specified in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.