How can I call properties a run time created button?
-
Hello! It is quite bit intrique because I am creating 80 buttons in runtime and assigning a name with an incremental value such as myButton.Name = "GButton_" + I.toString. Therefore, each button has a different name.
Dim I as Int32 For I = 1 to 5 Dim myButton as New Button myButton.Name = "GButton_" + I.toString me.controls.add(myButton) Next
How can I reach the GButton_3.backcolor property somewhere in code (out of the procedure where I create the buttons). Would it be possible to define the name and set its property? Is there a way to use such as EVAL function to perform something eval( "GButton_" + I.tostring + ".backcolor=" + setcolor) THANK YOU. :doh:
What a curious mind needs to discover knowledge is noting else than a pin-hole.
-
Hello! It is quite bit intrique because I am creating 80 buttons in runtime and assigning a name with an incremental value such as myButton.Name = "GButton_" + I.toString. Therefore, each button has a different name.
Dim I as Int32 For I = 1 to 5 Dim myButton as New Button myButton.Name = "GButton_" + I.toString me.controls.add(myButton) Next
How can I reach the GButton_3.backcolor property somewhere in code (out of the procedure where I create the buttons). Would it be possible to define the name and set its property? Is there a way to use such as EVAL function to perform something eval( "GButton_" + I.tostring + ".backcolor=" + setcolor) THANK YOU. :doh:
What a curious mind needs to discover knowledge is noting else than a pin-hole.
-
Hello! It is quite bit intrique because I am creating 80 buttons in runtime and assigning a name with an incremental value such as myButton.Name = "GButton_" + I.toString. Therefore, each button has a different name.
Dim I as Int32 For I = 1 to 5 Dim myButton as New Button myButton.Name = "GButton_" + I.toString me.controls.add(myButton) Next
How can I reach the GButton_3.backcolor property somewhere in code (out of the procedure where I create the buttons). Would it be possible to define the name and set its property? Is there a way to use such as EVAL function to perform something eval( "GButton_" + I.tostring + ".backcolor=" + setcolor) THANK YOU. :doh:
What a curious mind needs to discover knowledge is noting else than a pin-hole.
hi, it is easier as you think either you iterate the "Controls" collection of the Form: For Each ctl as Control In Me.Controls If ctl.Name = "GButton2" Then ctl.Backcolor .... Exit For End If Next or you just call the following: Me.Controls("GButton2").Basckcolor ... storing it in an array is not necessary, because the added controls are already stored in an collection (Me.Controls)
solidIT.de - under construction Components for Microsoft .Net audittrail, objectcomparer, deepcopy and much more ...
-
hi, it is easier as you think either you iterate the "Controls" collection of the Form: For Each ctl as Control In Me.Controls If ctl.Name = "GButton2" Then ctl.Backcolor .... Exit For End If Next or you just call the following: Me.Controls("GButton2").Basckcolor ... storing it in an array is not necessary, because the added controls are already stored in an collection (Me.Controls)
solidIT.de - under construction Components for Microsoft .Net audittrail, objectcomparer, deepcopy and much more ...
-
hi, it is easier as you think either you iterate the "Controls" collection of the Form: For Each ctl as Control In Me.Controls If ctl.Name = "GButton2" Then ctl.Backcolor .... Exit For End If Next or you just call the following: Me.Controls("GButton2").Basckcolor ... storing it in an array is not necessary, because the added controls are already stored in an collection (Me.Controls)
solidIT.de - under construction Components for Microsoft .Net audittrail, objectcomparer, deepcopy and much more ...
testy_proconsul wrote:
it is easier as you think
It's even easier than you think. ;)
testy_proconsul wrote:
storing it in an array is not necessary, because the added controls are already stored in an collection (Me.Controls)
Yes, of course it's not necessary, but it's the easiest and fastest way to get the reference.
--- single minded; short sighted; long gone;
-
testy_proconsul wrote:
it is easier as you think
It's even easier than you think. ;)
testy_proconsul wrote:
storing it in an array is not necessary, because the added controls are already stored in an collection (Me.Controls)
Yes, of course it's not necessary, but it's the easiest and fastest way to get the reference.
--- single minded; short sighted; long gone;
"i dont wanted to cut you short" ... guffa. and sorry for my bad english :) but opinion is to keep the overhead as small as possible and to use predefined functionality. generally this keeps overview, readability and conformity ...
solidIT.de - under construction Components for Microsoft .Net audittrail, objectcomparer, deepcopy and much more ...