get control parent

Byak@

Active Member
Licensed User
how can i get a parent of control?
yea?i may getcontrols() from all forms and panels and find.but it is very slow!
i think it is real with door lib.i'm find it in msdn Control.Parent - ???????? (System.Windows.Forms)

and try doorobj.getproperty("Parent") but it return empry string
 

agraham

Expert
Licensed User
Longtime User
This should work with a Basic4ppc Form and Panel but not with a FormEx. It returns the internal module and control name where the "." is replaced by an underscore and is prefixed by one (IDE/legacy compiled) or two (optimised compiled) underscores.
B4X:
obj.FromControl("Button1")
obj.Value = obj.GetProperty("Parent")
obj.Value = obj.GetProperty("propName")
 

Byak@

Active Member
Licensed User
yes,if parent of control is FormEx it's return CSenchancedForm(((
and getcontrols() not work with FormEx.
Agraham maybe you add this metod to FormEx?
 

agraham

Expert
Licensed User
Longtime User
Agraham maybe you add this metod to FormEx?
I cannot as a library control does not know its Basic4ppc name. However every control has a Tag property for programmer use so you could set all the Panel and Forms and FormEx Tag properties to their Basic4ppc names and use that to identify the parent.

B4X:
   obj.FromControl("Form1")
   obj.SetProperty("Tag", "Form1")
   obj.Value = obj.GetProperty("Tag")
   Msgbox(obj.Value)

   obj.Value = FormEx1.ControlRef
   obj.SetProperty("Tag", "FormEx1")
   obj.Value = obj.GetProperty("Tag")
   Msgbox(obj.Value)
 

Byak@

Active Member
Licensed User
big thanks agraham)
 
Top