Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Custom Base Form Class
Message
From
09/08/2007 13:45:53
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
 
 
To
09/08/2007 13:35:06
General information
Forum:
ASP.NET
Category:
Class design
Environment versions
Environment:
VB 8.0
Miscellaneous
Thread ID:
01246867
Message ID:
01247084
Views:
29
>>I tried about 10 different things, but for some reason I was too thick headed to think of that. I will try it out and let you know. Thanks!!!
>>
>>BTW, do you use a custom base form class?

>
>Of course!!! Doesn't everybody? =0)
>
>~~Bonnie

LOL. Is there an easy way to tell VS to have newly created forms derive from your base class instead of from the system class?


>
>
>
>
>
>>
>>>Mike, try putting the code in the Form's Load event instead of in the Constructor.
>>>
>>>~~Bonnie
>>>
>>>
>>>
>>>>I'm trying to, but it seems that in my Base Class it is always set to false. I am assuming this is because the form that is actually being designed is my Derived form.
>>>>
>>>>Basically, what I want to do is to change the text of the form to append a string if I am not in a production environment as determined by a value in the app.config file. I would like to have this done in my base class so I don't have to worry about it. Is there a better way of doing this?
>>>>
>>>>>Can't you use the DesignMode property? See http://weblogs.asp.net/fmarguerie/archive/2005/03/23/395658.aspx
>>>>>
>>>>>
>>>>>>I created a custom Base Form class, and I am trying to add logic in the constructor to append a string to the forms Text property based on a string in App.Config. I can make this work, but when I try to edit the derived form in VS in Design View I get an error indicating that it can't find the config file, which means that when a form is opened in Design view, it fires the constructor method. Is this correct, and if so, how can I do this without getting the error. Here is the Base Form class:
>>>>>>
>>>>>>
>>>>>>    <CLSCompliant(True)> _
>>>>>>    Public Class RAFForm
>>>>>>        Inherits System.Windows.Forms.Form
>>>>>>
>>>>>>        Public Sub New()
>>>>>>
>>>>>>            MyBase.New()
>>>>>>
>>>>>>            If AppEnvironment.CurrentEnvironment <> AppEnvironment.Environment.PRODUCTION Then
>>>>>>                MyBase.Text = String.Concat(MyBase.Text, " (", AppEnvironment.CurrentEnvironment.ToString, ")")
>>>>>>            End If
>>>>>>
>>>>>>        End Sub
>>>>>>
>>>>>>    End Class
>>>>>>
>>>>>>
>>>>>>The CurrentEnvironment method of the AppEnvironment class is a static method that reads from the config file and returns what environment is current set.
Very fitting: http://xkcd.com/386/
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform