Door Setproperty

pdabasic

Active Member
Licensed User
Hello!

I tried to build an skinning module.
I want to use like this:
B4X:
obj.Fromcontrol("TextBox1")
obj.SetProperty(propName,propVal)

propName: Left,Top,Width,Height,propVa=20l works fine

PropName=FontSize,propVal=12 isn't work

I don't understand, please HELP
 

pdabasic

Active Member
Licensed User
I understand this, but my problem is when I try to add the property name as variable.
I can't use like this:

var=FontSize
TextBox1.var=12
 

mjcoon

Well-Known Member
Licensed User
I understand this, but my problem is when I try to add the property name as variable.
I can't use like this:

var=FontSize
TextBox1.var=12

But, to echo Erel, why do you want to? It seems that you are mixing up the value of a variable, which is what is established by the "=", and the identity of the variable which is established by the "Dim" statement. A property of an object is analogous to a variable.

If Erel is correct:
There is no property named FontSize in .Net
then I do not understand why he also says:
You can just write:
TextBox1.FontSize = 12

If there is no such property then you cannot invent one!

Mike.
 

Basic4Life

Member
Licensed User
I understand this, but my problem is when I try to add the property name as variable.
I can't use like this:

var=FontSize
TextBox1.var=12


For your purpose it's probably best to parse the var instead of using it directly, something like
B4X:
Select var
 case ...
 case "FontSize"
         Textbox(name).Fontsize = 12
 case ...
End Select

But if you want to use the Door library it's a little more complicated

B4X:
   obj.New1(False) 'Door:Object
   obj.FromControl("TextBox1")
   
   objFont.New1(False) 'Door:Object
   objFont.CreateNew("System.Drawing.Font" & objFont.System_Drawing)  'Create new Font Object
   objFont.Value = obj.GetProperty("Font")  'Read out current Font
   
   fontfamily = objFont.GetProperty("FontFamily") ' Get current font family
   fontsize = 24  'new fontsize
   
   'objFont Properties are read-only so you have to create a new one instead of SetProperty
   
   'create arguments to create new font object
   
   objFontProp.New1(2) 'Door:ObjectArray
   objFontProp.SetValue(0,fontfamily,"System.String")  
   objFontProp.SetValue(1,fontsize,"System.Single")
   
   'create  new font object
   objFont.CreateNew2("System.Drawing.Font" & objFont.System_Drawing,objFontProp.Value)
   
   'Set the new font object
   obj.SetProperty2("Font",objFont.Value)
 

Attachments

  • Door_ChangeFontSize.sbp
    1.4 KB · Views: 209

pdabasic

Active Member
Licensed User
Thank you everybody!

I choosed a mixed solution like this:

B4X:
Case "TextBox"
         If propName="FontSize" Then
            TextBox(ctrlName).FontSize=propVal
            Return
         Else
            Object("doorCrtlProp").FromControl(ctrlName)
         End If
End Select
Object("doorCrtlProp").SetProperty(propName,propVal)
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…