title: Using a static DataSet as DataSource
body: <p>In my application I have a DataSet that holds tables that are used in different forms, all over my application.
  To be able to maintain concurrency between forms, and not having to get data from the database every time the user opens a new form, I hold my DataSet as a static field in the program class like this:  </p>
  
  <pre><code>static class Program
  {
      public static CustomDataSet StockDataSet { get; private set; }
  
      [STAThread]
      static void Main()
      {
          StockDataSet = new Database.CustomDataSet();
          StockDataSet.InitRelations();
          StockDataSet.EnforceConstraints = false;
          StockDataSet.Categories.Fill();
          StockDataSet.Suppliers.Fill();
          StockDataSet.StockItems.Fill();
          StockDataSet.EnforceConstraints = true;
  
          Application.EnableVisualStyles();
          Application.SetCompatibleTextRenderingDefault(false);
          Application.Run(new MainWindow());
      }
  </code></pre>
  
  <p>This makes it pretty easy to use the DataSet programatically. Working in the design-time however causes allot of frustration. For examle; I have a form with a DataGridView bound to a BindingSource. If I want to be able to work with the columns of the DataGridView in design-time, I must have an object of my custom DataSet accessible to the BindingSource in the InitializeComponent.</p>
  
  <p>All workarounds for this I can think of are pretty ugly hacks.
  Like using a dummy object in Designer.cs to keep the design-time happy, and then assign the static object to the field holding the dummy object. And after that reset all the bindings in in the constructor. This must be considered very bad practice, right?</p>
  
  <p><strong>So my question is this:</strong> Isn't there a more elegant, or at least practical approach to this?
  Or are there any suggested best-practices for working with DataSets in multiple forms?</p>
  
  <p><strong>Edit</strong><br>
  Stock refers to stock keeping as in inventory. No heavy processing is done on the data, which is kept on a MySql-database on a local server. </p>