title: displaying multiple datatable in tabcontrol C#
body: <p>i have a small program that takes a datatable (takes data from sql database)
  then splits it into datatable array by field and then should display it in a tabcontrol, each field in it's own tab</p>
  
  <p>the split, takes single datatable and splits into datatable array, works fine i think</p>
  
  <pre><code>public DataTable[] splitTable(DataTable mainDT,string columnName)
      {
          int tmp=0;
          DataTable[] splitDT = new DataTable[11];
          for (int i=0;i&lt;11;i++)
              splitDT[i]=new DataTable();
  
  
  
          foreach (DataRow row in mainDT.Rows)
          {              
             tmp = row[columnName].GetHashCode();
             splitDT[tmp].ImportRow(row);
          }
          return splitDT;
      }
  </code></pre>
  
  <p>here is the problem part</p>
  
  <pre><code>public Display(string Name, string rname, DataTable[] left,int tabNum)
      {
          InitializeComponent();
          TabPage tp;
          DataGridView dgw;
  
          lLeftTable.Text = Name;
  
          for (int i = 0; i &lt; tabNum;i++ )
          {
              tp = new TabPage(""+i);
              dgw = new DataGridView();
              dgw.DataSource = left[i];
              tp.Controls.Add(dgw);
              tbcLeftPages.Controls.Add(tp);
              tbcLeftPages.Refresh();
          }
  
      }
  </code></pre>
  
  <p>it opens a tabcontrol with the right amount of tabs but no data in them</p>
  
  <p><strong>EDIT 1</strong> still no good, show tabs with no gridview
  changed it into a function that get's parts of the datatable array</p>
  
  <pre><code> public void addDGWtoTab(DataTable dt,string side,int num)
          {
          MessageBox.Show("table:" + side + " bucket:" + num + "rows:" + dt.Rows.Count);
          DataGridView dgw = new DataGridView();
          TabPage tp = new TabPage();
  
          //data grid view
          dgw.Name = "dgv" + num;
          dgw.AutoSize = true;
          dgw.Dock = DockStyle.Fill;
  
          //tab page
          tp.Name = "tp" + num;
          tp.Text = "Bucket " + num;
          tp.Tag = dt.Rows.Count;
          tp.TabIndex = num;
  
          if (side == "left")             
              tbcLeftPages.Controls.Add(tp);   
          else tbcRightPages.Controls.Add(tp);
          dgw.DataSource = dt; 
          tp.Controls.Add(dgw);
  
      }
  </code></pre>
  
  <p><strong>EDIT 2</strong>
  added spitDT</p>
  
  <pre><code>public DataTable[] splitTable(DataTable mainDT,string columnName,int mod)
      {
          DataTable[] splitDT = new DataTable[11];
          for (int i=0;i&lt;11;i++)
              splitDT[i]=new DataTable();
  
          int splitINT;
          int tmp=0;
  
          foreach (DataRow row in mainDT.Rows)
          {              
             splitINT = row[columnName].GetHashCode();
             tmp = splitINT % mod;
             splitDT[tmp].ImportRow(row);
          }
  
          return splitDT;
      }
  </code></pre>
  
  <p><strong>EDIT 3</strong> split with messages</p>
  
  <pre><code>public DataTable[] splitTable(DataTable mainDT,string columnName,int mod)
      {
          DataTable[] splitDT = new DataTable[11];
          for (int i=0;i&lt;11;i++)
              splitDT[i]=new DataTable();
  
          int splitINT;
          int tmp=0;
  
          foreach (DataRow row in mainDT.Rows)
          {              
             splitINT = row[columnName].GetHashCode();
             tmp = splitINT % mod;
             splitDT[tmp].ImportRow(row);
             MessageBox.Show("value:" + row[columnName].ToString() + "splitINT:" + splitINT + "mod:" + mod +
                              " to table:" + tmp);
              MessageBox.Show("" + splitDT[tmp].Rows.Count);
          }
  
          return splitDT;
      }
  </code></pre>