Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do you get this done?
Message
From
23/01/2009 15:05:39
 
 
To
22/01/2009 21:03:38
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01376440
Message ID:
01376619
Views:
6
OK. I think I'm on the home stretch on this one with one exception. I have an enumeration "Direction" as follows:

enum Direction { Next, Previous, First, Last, Refresh };

I've tried to use it as follows:

if (this.TopLevelControl is AppObject)
{
App thisApp = ((AppObject)this.TopLevelControl).oApp;
thisApp.db.Navigate(TableName, Direction.Next);
}

Here's the error:

The name 'Direction' does not exist in the current context

I've tried duplicating the enum from my db object in this button object and I get this error:

Argument '2': cannot convert from 'Marketware.NextButton.Direction' to 'Marketware.Db.Direction'

How do I get this enum to work in this button? THANKS!!

Bob




>Bob,
>
>Maybe you mean something like this?
>
>
>App thisApp = this.TopLevelControl as App;
>
>if (thisApp != null)
>    thisApp.db.Navigate("contact",Direction.Next);
>
>
>But, probably not (this isn't exactly the same thing you coded below). I'm thinking you want to maybe use Interfaces, such that any thing that can be a TopLevelControl should implement your INeedoApp interface. Then you could do this:
>
>
>if (this.TopLevelControl is INeedoApp)
>{
>    App thisApp = ((INeedoApp)this.TopLevelControl).oApp;
>
>    thisApp.db.Navigate("contact",Direction.Next);
>}
>
>
>~~Bonnie
>
>>In FoxPro I created a bunch of buttons that activated functionality in an application object that I built, and then I'd just drop the button on a form and VOILA all I had to do is populate a couple of properties at design time and away it went. Now, to get that same functionality in .NET...
>>
>>Here's the classe's click code and maybe you can see my problem.
>>
>>(App is a type in my main classes, and oApp is a property that holds an instance of the App object on the active form.)
>>
>>
>>****************************************************
>>
>>App thisApp = (App)this.TopLevelControl.oApp;
>>
>>thisApp.db.Navigate("contact",Direction.Next);
>>
>>
>>**************************************************
>>When I attempt to complile the above it doesn't know what to do with oApp as its not a property of the 'System.Windows.Forms.Control'.
>>
>>Sure, I can set this code on each button on my form, but I like to create classes so I can reuse my code.
>>
>>What am I missing, or is this just the situation with C# and you can't do this kind of thing in C# like you can in FoxPro? I can't pass an oApp to each button on my form...and I'm assuming there isn't really a thing like a global variable that the compiler can see.
>>
>>Thanks!!
>>
>>Bob
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform