Conditionally loading global variables
-
Hi, I declare various objects to be available in a form immediately in the class declaration eg public partial class MainForm : Form { int totalCourts; int totalViewPeriods; int totalBookingPeriods; int minimumBookingPeriods; etc... What I want to do is declare objects conditionally ie if a variable = say 9 then make an object available. Specifically I want to make tableadapters made at design time to be available at runtime. Is there some way to make these available in the Form Load event?
Glen Harvy
-
Hi, I declare various objects to be available in a form immediately in the class declaration eg public partial class MainForm : Form { int totalCourts; int totalViewPeriods; int totalBookingPeriods; int minimumBookingPeriods; etc... What I want to do is declare objects conditionally ie if a variable = say 9 then make an object available. Specifically I want to make tableadapters made at design time to be available at runtime. Is there some way to make these available in the Form Load event?
Glen Harvy
Your best bet is to make the object available via a property which can throw an exception or return null if you don't want it to be available.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )