Home
Browse all 647 examples
Download all 647 examples
Download sample chapters
Reviews
Errata
Acknowledgments
Links on .NET
Paradoxal Press

Buy directly from Paradoxal Press at $33.99 (Save 43%)



Category: Programming
Level: Beginner to seasoned
900 pages
ISBN-10 097661322-0
ISBN-13 978-097661322-0
$59.99 USA
$79.99 CANADA


Listing 18-5 extracted from chapter Windows forms applications


Listing 18-4<     > Listing 18-6


This listing can be compiled with the command line:
csc.exe /target:exe Example_18_5.cs
Errors: 5 Warnings: 0


Example_18_5.cs
using System.ComponentModel;
using System.Data;
using System.Windows.Forms;
// NOTE: The typed DataSet ORGANIZATIONDataSet must be declared 
//        in the namespace WindowsApplication1.
using WindowsApplication1;
using WindowsApplication1.ORGANIZATIONDataSetTableAdapters;

public class MyForm : Form {
   public MyForm() {
      InitializeComponent();
   }
   private void Form1_Load(System.Object sender, System.EventArgs e) {
      depDataGridView.DataSource = dSet.DEPARTMENTS;
      empDataGridView.DataSource = dSet.EMPLOYEES;
      depTableAdapter.Fill(dSet.DEPARTMENTS);
      empTableAdapter.Fill(dSet.EMPLOYEES);  
   }
   private void InitializeComponent() {
      this.components = new Container();
      this.empDataGridView = new DataGridView();
      this.depDataGridView = new DataGridView();
      this.depTableAdapter = new DEPARTMENTSTableAdapter();
      this.empTableAdapter = new EMPLOYEESTableAdapter();
      this.dSet = new ORGANIZATIONDataSet();
      ((ISupportInitialize)(this.empDataGridView)).BeginInit();
      ((ISupportInitialize)(this.depDataGridView)).BeginInit();
      ((ISupportInitialize)(this.dSet)).BeginInit();
      this.SuspendLayout();

      empDataGridView.Dock = DockStyle.Fill;
      depDataGridView.Dock = DockStyle.Fill;
      SplitContainer splitContainer1 = new SplitContainer();
      splitContainer1.Dock = DockStyle.Fill;
      splitContainer1.Orientation = Orientation.Vertical;
      splitContainer1.Panel1.Controls.Add(depDataGridView);
      splitContainer1.Panel2.Controls.Add(empDataGridView);
      this.Controls.Add(splitContainer1);

      this.Text = "Form DEPARTMENTs/Employees";
      this.Load += new System.EventHandler(this.Form1_Load);
      ((ISupportInitialize)(this.empDataGridView)).EndInit();
      ((ISupportInitialize)(this.depDataGridView)).EndInit();
      ((ISupportInitialize)(this.dSet)).EndInit();
      this.ResumeLayout(false);
   }
   private IContainer components = null;
   private DataGridView empDataGridView;
   private DataGridView depDataGridView;
   private DEPARTMENTSTableAdapter depTableAdapter;
   private EMPLOYEESTableAdapter empTableAdapter;
   private ORGANIZATIONDataSet dSet;
}	
Copyright Patrick Smacchia 2006 2007