Accessing Textbox in different Class

Posted by stingray70m on 14-Dec-2016 11:16

I have a Telerik form(FormA.cls) that contains a textbox (vTextbox1). FormA also dynamically loads a separate Radform class (FormB.cls) into a Tab. FormB contains a button (bButton) and textbox (vTextbox2). If I create a click event in bButton,  what is the best way to get the value in vTextbox1 to display in vTextbox2 or viceversa?

Thanks

Mark

All Replies

Posted by marian.edu on 14-Dec-2016 12:20

Either use a public method to get/set the textbox value or go for publish/subscribe - aka, named events in your case… the later has the advantage of not strongly coupling the two classes with the drawback of being slightly more ‘complicate’ and asynchronous.


Whatever you do just try not to go with the easy way and make the textview property public.

Marian Edu

Acorn IT 
+40 740 036 212

Posted by stingray70m on 15-Dec-2016 10:32

Thanks! Could you provide me with an example of how to programmatically access the textbox value? I'm still relatively new to programming in Developer Studio and can't get my head around how to access the value on the screen.  

I've created a  method in FormA:

 method public character GetFields( ):

       define variable aa as character initial "abc" no-undo.

       aa = this-object:vTextbox1:text.   <-- if I pass "abc" instead of the Textbox1:text it works.

       return aa.

   end method.

In FormB:

method private void bButton_Click( input sender as System.Object, input e as System.EventArgs ):

define variable fOBJ as FormA no-undo.

               fOBJ = new FormA().      < -this  is my problem.. initializes the form but don't know another way

               this-object:vTextbox2:text = fOBJ:GetFields().        

        return.

end method.

Thanks

Mark

Posted by Daniel Ruiz on 15-Dec-2016 11:11

you can try send a paramater like this way:

_____________________ FormB __________________________

CONSTRUCTOR PUBLIC   FormB  (

       INPUT myCharacter AS CHARACTER

       ):

_____________________ FormA __________________________

DEFINE VARIABLE fOBJ  AS CLASS  FormB NO-UNDO.

fOBJ = new FormB(myCharacter).

This thread is closed