I guess what I have to do is quite simple, but I'm really stuck!
I need to create, in a form, a particular number "i" of "Button"s (i is given at runtime), whose reference name should be "button1","button2", ...
I mean something like: Button button1 = new System.Windows.Forms.Button(); ...
So I tried with a "for" looping i times, ech time to create a new Button called button; I wrote a function that, given parameter i, returns the string "button<i>".
This function is called each loop, but I can't manage to make this "button<i>" string become the reference name of the new created button, thus getting a separate object from the previous.
I hope to have been clear.
Thanx a lot in advance, for whoever'll try to help me!
Davide
//Trying desperetely to end up my thesis on time
4 1092
You can creat an Array or an ArrayList of Buttons and stash your buttons in there. You can write a single method to hand the click event and then associate it with each button as it is created. Note: You'll need to do this in the Page_Init method, so that everytime your page is refreshed, the buttons are recreated.
Hope that helps.
You can creat an Array or an ArrayList of Buttons and stash your buttons in there. You can write a single method to hand the click event and then associate it with each button as it is created. Note: You'll need to do this in the Page_Init method, so that everytime your page is refreshed, the buttons are recreated.
Hope that helps.
Thank you for the advice, I think I understood..just one thing: by Page_Init you mean the constructor of the form i'm talkin about, right?
I have a problem, then:
The form I have to create as I told u (AppWin) is called inside the main Application.Run (new StartUp), where StartUp is another form that is needed at the beginning to perform some initial operation and to decide how AppWin must be looking like.
But when I call the constructor of AppWin, how can I turn the control of the application on this form instead than on the previous one?
I mean, as how my program works by now, AppWin is created and after its constructor ends, the first form StartUp is again shown and active.
Instead, how can I have AppWin active in full screen mode so that the buttons can be clickable?
Thanx very much!!!
Duh, I should have read your first post more clearly. Of coures there's no Page_Init in Forms.
After you create an instance of AppWin with the constructor, use the AppWin.Show() method to display the form. When you are done using the form, use the Dispose() method.
Hope that helps.
Thank you for the advice, I think I understood..just one thing: by Page_Init you mean the constructor of the form i'm talkin about, right?
I have a problem, then:
The form I have to create as I told u (AppWin) is called inside the main Application.Run (new StartUp), where StartUp is another form that is needed at the beginning to perform some initial operation and to decide how AppWin must be looking like.
But when I call the constructor of AppWin, how can I turn the control of the application on this form instead than on the previous one?
I mean, as how my program works by now, AppWin is created and after its constructor ends, the first form StartUp is again shown and active.
Instead, how can I have AppWin active in full screen mode so that the buttons can be clickable?
Thanx very much!!!
I hope I did not misunderstand you
Following is what I did in VB, seems to be working -
-
For i As Integer = 0 To 5
-
Dim Button As New System.Windows.Forms.Button
-
Me.SuspendLayout()
-
Button.Location = New System.Drawing.Point(112, 96 + i * 96)
-
Button.Name = "Button" + i.ToString
-
Button.TabIndex = 0
-
Button.Text = "Button" + i.ToString
-
Me.Controls.Add(Button)
-
Next
-
You definitely know you can play with the object location and size
Regards
Sign in to post your reply or Sign up for a free account.
Similar topics
by: James Hong |
last post by:
Help please, I try to sending an email from my html page using the java
applet.
but it give error on most of the PC only very few work, what is the error i
make
the java applet show as below
...
|
by: raulgz |
last post by:
hi
I need generate dinamic sql:
I need a select sentence with all fields of one table 't1'
and all fields of tables which 't1' have foreings keys 't1 ( reflexive ) ,t2,t3,...'
Now, l have de...
|
by: dddddd |
last post by:
i need do create simple dinamic site - built mainly
of pictures(they are the only dinamic part).
pictuers differ by the -Location- and by -Time- (in which
they were taken)... so on the index...
|
by: Jose Garcia |
last post by:
Hi there,
Can somebody explain me how can i use matrixes with dinamic memory? I
use malloc and free (NOT new & delete). I want to access to the matrix
like Matrix but i don't know how to do that...
|
by: gp |
last post by:
Hi all,
I'm using Microsoft Visual C++ 6.0,
I would like to see, debugging my project, all the elements of my dinamic
objects....
I have a dinamic array and a STL vector and I need to know...
|
by: Morgan |
last post by:
I have read much posts on the argument but no one
clearly says if this operation is possible or not.
Simply I have a routine which reads from a text
file some integer arrays (1 or 2D).
The...
|
by: Alessandro |
last post by:
i want to create dinamicaly an image Button, but i'm not able to associate a
relative server command on click, any idea ?
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As...
|
by: Liqun Xu |
last post by:
Hallo NG,
I created a Button with Click-Event dynamically:
System.Web.UI.WebControls.Button bt_1 = new Button();
bt_1.Click += new EventHandler(bt_1_click);
and I implemented the Funktion...
|
by: javuchi |
last post by:
I just want to share some code with you, and have some comments and
improvements if you want.
This header file allocates and add and delete items of any kind of data
from a very fast array:
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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,...
|
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...
| |