Hi Patrick
by "LinkButtons" I assume you are refering to LinkLabels, but anyways it
should work just the same for all controls.... so...
There are a few ways to go about it. If you know from the get go, how many
LinkLabels you will have dynamically created after runtime, you can declare
those controls in your code like this:
private LinkLabel[] _myLinkLabel = new LinkLabel[100]; // declaring 100
link labels
.... then in your code somewhere... depending when you need to create the
labels... say on some other Button you have in your form of which the user
needs to press...
private void SomeButton_Clicked( Object sender, System.EvenHandler e )
{
_myLinkLabel[ _labelCounter ] = new LinkLabel();
_myLinkLabel[ _labelCounter ].Name = "New Label";
_myLinkLabel[ _labelCounter ].Text = "Some text";
..
..
..
// some more code here
..
..
..
}
and that should be it..... UNLESS!!! you have something like a Panel on your
form.... of which will obscure any object under it, if it is not added to
the panel....
so to add a control to a panel...like the link label, you need
SomePanel.Controls.Add( _myLinkLabel[ _labelCounter ] );
then you would probably need to re locate your control so that it is where
you want it to be on your form.
Also... I would recomend using ArrayLists if you don't know how many labels
you will need after runtime. That way you don't really need declare your
label because an ArrayList takes any kind of object... and to access it
later on...to modify it you can either use the Controls property from you
form or the Panel if it belongs to a panel.
hope that helps
Patrick Marti said:
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