>Hi All,
>
>I try to make my first steps in DotNet world and I would like to ask you three (simple ?) questions.
>
>1. In C# (VS 2003) Is possible to execute a method for a control when we have its name in a variable ?
> In my VFP framework I do this:
> IF VARTYPE(thisform.cfrmpanel)="C" then
> lcObjectName = "thisform." + thisform.cFrmPanel
> EVALUATE(lcObjectName + ".OnBeforeClose()")
> ENDIF
>
> Is it possible with C# ?
Yes, sort of. But it's not really the best way to handle this. In .NET, they support the idea of "Interfaces". Instead of checking for a specific property, you set your method to only accept objects which implement the interface you are interested in. Then it becomes safe to directly call methods/properties on that object. The compiler will make sure everything you pass implements this interface. Instead of passing in the object name, you'd pass in an actual object reference (or iterate through a collection of objects looking for a specific one). The implementation of this is different than in VFP.
>
>3. Is there a With Statement (or equivalent) in C# ?
>
> lcObjectName = "thisform." + lcPanelName
> IF VARTYPE(lcObjectName)="O" THEN
> WITH &lcObjectName
> .top = this.xpanel_guide1.Top
> .left = this.xpanel_guide1.Left
> .width = this.xpanel_guide1.Width
> ENDWITH
> ENDIF
No.