On 01/10/2015 03:33 PM, Tobias Boege wrote:
> On Sat, 10 Jan 2015, T Lee Davidson wrote:
>>> If Panel1's containing Form is FForm, then you can do
>>>
>>>     FForm.Controls["TextBox1"]
>>>
[snip]
>>>
>>
>> Thanks for the elucidation, Tobi. But, I must be missing something.
>>
>> FForm.Controls["TextBox1"] returns a Control which does not have a Text 
>> property.
>>
>> .Parent ("Panel1.Parent") returns a Container which also does not have a 
>> Text property.
>>
>> If we do something like
>>
>>      Dim hForm As Form
>>      If Panel1.Parent Is Form Then hForm = Panel1.Parent
>>
>> we would have hForm.Controls["TextBox1"], which returns a Control with no 
>> Text property.
>>
>
> It returns an object *typed* as a Control. But if the object is actually a
> TextBox, say, you can "cast" that Control to a TextBox, with something like
>
>    Dim hControl As Control
>    Dim hTextBox As TextBox
>
>    hControl = FForm.Controls["TextBox1"]
>    If hControl Is TextBox Then
>      hTextBox = hControl
>      ' ...
>    Endif
>
> Since now the type of the hTextBox variable says "TextBox", and the object
> behind it has a Text property, this property can successfully be resolved.

That's great, Tobi. So then Martin can do something like:

   Dim hForm As Form
   Dim hControl As Control
   Dim hTextBox As TextBox

   If Panel1.Parent Is Form Then
     hForm = Panel1.Parent
     hControl = hForm.Controls["TextBox1"]
     If hControl Is TextBox Then
       hTextBox = hControl
       Print hTextBox.Text
     Endif
   Endif

I tried it. It works.


> As for the hijacking, my bad. But I didn't understand Martin's question
> either way, so let's pretend I thought this was relevant to the thread :-)

Lol. Okay. :-)


Lee
__________

"Artificial Intelligence is no match for natural stupidity."

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to