473,976 Members | 25,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create button control at runtime

This one should be easy ;)
How can I create a button control at runtime using one that is already
created and adjust the properties ?

Thanks in advance

Dec 15 '06 #1
4 3353

WebNewsReader wrote:
This one should be easy ;)
How can I create a button control at runtime using one that is already
created and adjust the properties ?

Thanks in advance
So you want a clone of an existing button, then change one or two
things?

Well, just creating a new button is easy:

Dim b as new system.windows. forms.form.Butt on

I don't think buttons have a clone method, so you could make a
ClonableButton by defining a new class tha inherits Button and
implements ICloneable.
Or just set the properties you want (for quick and dirty solution):
b.property1 = oldButton.prope rty1
b.property2 = oldButton.prope rty2
....

Dec 15 '06 #2
ok, that fixes my needs
but there is a way to create using an array ?

<lo*********@gm ail.comwrote in message
news:11******** **************@ 73g2000cwn.goog legroups.com...
>
WebNewsReader wrote:
>This one should be easy ;)
How can I create a button control at runtime using one that is already
created and adjust the properties ?

Thanks in advance

So you want a clone of an existing button, then change one or two
things?

Well, just creating a new button is easy:

Dim b as new system.windows. forms.form.Butt on

I don't think buttons have a clone method, so you could make a
ClonableButton by defining a new class tha inherits Button and
implements ICloneable.
Or just set the properties you want (for quick and dirty solution):
b.property1 = oldButton.prope rty1
b.property2 = oldButton.prope rty2
...
Dec 15 '06 #3

WebNewsReader wrote:
ok, that fixes my needs
but there is a way to create using an array ?
So now you want an array filled with buttons, huh? Ok!

You can try this:
dim btnArray as new ArrayList(10) 'estimate the capacity you'll need. I
guessed at "10".
there are other structures you can use, such as a generic list.

then you can add buttons like this:
dim myButton as new Button
btnArray.add(my Button)

and loop through the array like this:
for each btn as Button in btnArray
...
'some code goes in here
next

Dec 15 '06 #4


<lo*********@gm ail.comwrote in message
news:11******** *************@8 0g2000cwy.googl egroups.com...
>
WebNewsReader wrote:
>ok, that fixes my needs
but there is a way to create using an array ?

So now you want an array filled with buttons, huh? Ok!

You can try this:
dim btnArray as new ArrayList(10) 'estimate the capacity you'll need. I
guessed at "10".
there are other structures you can use, such as a generic list.

then you can add buttons like this:
dim myButton as new Button
btnArray.add(my Button)

and loop through the array like this:
for each btn as Button in btnArray
...
'some code goes in here
next
Hmm, if the number of buttons are known at compile-time, or even at runtime
prior to creating the buttons, I would use an array rather than arraylist.
But if the total number of buttons are unknown until they are all created,
then using an ArrayList or List would be the way to go (I'm unfamiliar with
the List<generic class, so you may also want to look into this as it may
be just as efficient as using a normal array, but I'm not sure)...

HTH,
Mythran
Dec 15 '06 #5

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

Similar topics

5
1508
by: Patrick Marti | last post by:
I wish to create some LinkButtons in DotNet. Because I will do it in dependence of the entries in a database, I can not add them with the mouse to the form as usually. I can create them in the Page_Load event but then I can not see them. I do not know the reason or how to do it correctly. Do anywhere know something about? For any help, I thanks a lot Greetings Patrick Marti
3
1810
by: leon | last post by:
hello friends, i am writing a page aspx and creating controls dinamicaly and then i must to create for each control the events as well. Anybody to know how????? happy day lion
8
21634
by: frankcvc | last post by:
I created a control array at runtime using the following code. I also wanted to code the controlarray click event. My code can respond to click event but cannot identify the specific control clicked on, which is important to my application. Appreciate your help. Frank --------------------------- private void initBoard()
4
2095
by: Dale Levesque | last post by:
I get this message. any ideas?? See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
7
11369
by: Matt | last post by:
Hi all, I'm trying to create a system where it reads a number of records from a database and then creates a row in the GUI that contains a single field from the database and a button that has a reference to the record. This way, once the task has been accomplished, the button can be pressed next to the field and a time-stamp is placed into the database. Can anyone point me in the direction of either a tutorial or
1
1715
by: amitsaxena1981 | last post by:
Hi, I am using asp.net with vb.net and creating the user control .My user control generate the table at runtime in which each column has button so i want to create the event handler for each run time generated button Onclick .I Do not want to use the attribute.add .Please suggest me how to raise the event from the page when be drop this control . waiting for your hopefully response.... Thanks and Regards Amit
3
18734
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however, working with complex reports is tricky Assumption: Reader of this article have basic knowledge of creating data reports. Creating a Parent-Child Command and create a DataReport Suppose we have a database called company with two tables ...
3
1564
by: chandan | last post by:
Hi, Is any way to palce a control(button/label) at a location on webPage in runtime?? In page_load envet I am adding a button on the page in the contol collection of a panel but not able to specify the location of the button since button controls did not have location property in web. I am trying to place a control at mouse click position on the page.also I am not getting the mouse down position on the page I am
0
1806
by: Brian Roisentul | last post by:
Hi All, I want to programmatically(c# fmw 2.0) create a folder under my IIS Web Site. I figured that I needed to create an entry in the IIS Metabase. So, after investigating a while and i figured out something pretty weird: I downloaded a source code that allowed me to do what I wanted.
0
10353
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
11818
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
11408
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...
0
10083
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6557
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5153
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
4731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3761
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.