Hi all,

I am trying to use a variable which retrieves an object name, such as

string objObject = databaseobject("Fieldname")

and using the objObject to refer to a object, such as a button, textbox
or form within the current form and changing stuffs like objObject.text =
"blahblahblah".

Is this possible? If so, how?

thanks.

RE: Using variables as Objects Name by Rotciv

Rotciv
Fri Sep 22 14:39:01 CDT 2006

Hey all,

Well.. i found the answer, it is as follows

this.Controls[(string)databaseobject("Fieldname")].Visible = false;

"Rotciv" wrote:

> Hi all,
>
> I am trying to use a variable which retrieves an object name, such as
>
> string objObject = databaseobject("Fieldname")
>
> and using the objObject to refer to a object, such as a button, textbox
> or form within the current form and changing stuffs like objObject.text =
> "blahblahblah".
>
> Is this possible? If so, how?
>
> thanks.

Re: Using variables as Objects Name by ThunderMusic

ThunderMusic
Fri Sep 22 15:35:24 CDT 2006

I advise you to put this statement between try...catch or to validate first
if your control exists (and does not return null) because you will have
exceptions fusing all over the place if it doesn't exist... ;)

You may also want to explore System.Runtime.Reflection to retrieve/invoke
your object's properties and methods at runtime.

I hope it helps

ThunderMusic

"Rotciv" <Rotciv@discussions.microsoft.com> wrote in message
news:47EC6C6F-E05D-45BA-AD60-7FFA42438FF0@microsoft.com...
> Hey all,
>
> Well.. i found the answer, it is as follows
>
> this.Controls[(string)databaseobject("Fieldname")].Visible =
> false;
>
> "Rotciv" wrote:
>
>> Hi all,
>>
>> I am trying to use a variable which retrieves an object name, such as
>>
>> string objObject = databaseobject("Fieldname")
>>
>> and using the objObject to refer to a object, such as a button,
>> textbox
>> or form within the current form and changing stuffs like objObject.text =
>> "blahblahblah".
>>
>> Is this possible? If so, how?
>>
>> thanks.



Re: Using variables as Objects Name by Stoitcho

Stoitcho
Fri Sep 22 15:58:40 CDT 2006

Roticv,

Just keep im mind that controls my not have name. If they are created in the
designer they always do, but I doubt some one bother giveing names to
controls created by code.


--
Stoitcho Goutsev (100)

"Rotciv" <Rotciv@discussions.microsoft.com> wrote in message
news:47EC6C6F-E05D-45BA-AD60-7FFA42438FF0@microsoft.com...
> Hey all,
>
> Well.. i found the answer, it is as follows
>
> this.Controls[(string)databaseobject("Fieldname")].Visible =
> false;
>
> "Rotciv" wrote:
>
>> Hi all,
>>
>> I am trying to use a variable which retrieves an object name, such as
>>
>> string objObject = databaseobject("Fieldname")
>>
>> and using the objObject to refer to a object, such as a button,
>> textbox
>> or form within the current form and changing stuffs like objObject.text =
>> "blahblahblah".
>>
>> Is this possible? If so, how?
>>
>> thanks.