Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
Friend WithEvents TabPage2 As System.Windows.Forms.TabPage
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents DataGrid2 As System.Windows.Forms.DataGrid
Friend WithEvents DataSet1 As System.Data.DataSet
Friend WithEvents DataTable1 As System.Data.DataTable
Friend WithEvents DataTable2 As System.Data.DataTable
Friend WithEvents DataColumn1 As System.Data.DataColumn
Friend WithEvents DataColumn2 As System.Data.DataColumn
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TabControl1 = New System.Windows.Forms.TabControl()
Me.TabPage1 = New System.Windows.Forms.TabPage()
Me.DataGrid1 = New System.Windows.Forms.DataGrid()
Me.TabPage2 = New System.Windows.Forms.TabPage()
Me.DataGrid2 = New System.Windows.Forms.DataGrid()
Me.DataSet1 = New System.Data.DataSet()
Me.DataTable1 = New System.Data.DataTable()
Me.DataColumn1 = New System.Data.DataColumn()
Me.DataTable2 = New System.Data.DataTable()
Me.DataColumn2 = New System.Data.DataColumn()
Me.TabControl1.SuspendLayout()
Me.TabPage1.SuspendLayout()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.TabPage2.SuspendLayout()
CType(Me.DataGrid2, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.DataSet1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.DataTable1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.DataTable2, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'TabControl1
'
Me.TabControl1.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.TabControl1.Controls.AddRange(New System.Windows.Forms.Control() {Me.TabPage1, Me.TabPage2})
Me.TabControl1.Location = New System.Drawing.Point(16, 16)
Me.TabControl1.Name = "TabControl1"
Me.TabControl1.SelectedIndex = 0
Me.TabControl1.Size = New System.Drawing.Size(472, 336)
Me.TabControl1.TabIndex = 0
'
'TabPage1
'
Me.TabPage1.Controls.AddRange(New System.Windows.Forms.Control() {Me.DataGrid1})
Me.TabPage1.Location = New System.Drawing.Point(4, 22)
Me.TabPage1.Name = "TabPage1"
Me.TabPage1.Size = New System.Drawing.Size(464, 310)
Me.TabPage1.TabIndex = 0
Me.TabPage1.Text = "TabPage1"
'
'DataGrid1
'
Me.DataGrid1.DataMember = ""
Me.DataGrid1.DataSource = Me.DataTable1
Me.DataGrid1.Dock = System.Windows.Forms.DockStyle.Fill
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.ReadOnly = True
Me.DataGrid1.Size = New System.Drawing.Size(464, 310)
Me.DataGrid1.TabIndex = 0
'
'TabPage2
'
Me.TabPage2.Controls.AddRange(New System.Windows.Forms.Control() {Me.DataGrid2})
Me.TabPage2.Location = New System.Drawing.Point(4, 22)
Me.TabPage2.Name = "TabPage2"
Me.TabPage2.Size = New System.Drawing.Size(464, 310)
Me.TabPage2.TabIndex = 1
Me.TabPage2.Text = "TabPage2"
'
'DataGrid2
'
Me.DataGrid2.DataMember = ""
Me.DataGrid2.DataSource = Me.DataTable2
Me.DataGrid2.Dock = System.Windows.Forms.DockStyle.Fill
Me.DataGrid2.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid2.Name = "DataGrid2"
Me.DataGrid2.ReadOnly = True
Me.DataGrid2.Size = New System.Drawing.Size(464, 310)
Me.DataGrid2.TabIndex = 0
'
'DataSet1
'
Me.DataSet1.DataSetName = "NewDataSet"
Me.DataSet1.Locale = New System.Globalization.CultureInfo("en-NZ")
Me.DataSet1.Tables.AddRange(New System.Data.DataTable() {Me.DataTable1, Me.DataTable2})
'
'DataTable1
'
Me.DataTable1.Columns.AddRange(New System.Data.DataColumn() {Me.DataColumn1})
Me.DataTable1.TableName = "Table1"
'
'DataColumn1
'
Me.DataColumn1.ColumnName = "Column1"
'
'DataTable2
'
Me.DataTable2.Columns.AddRange(New System.Data.DataColumn() {Me.DataColumn2})
Me.DataTable2.TableName = "Table2"
'
'DataColumn2
'
Me.DataColumn2.ColumnName = "Column1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(504, 366)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.TabControl1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.TabControl1.ResumeLayout(False)
Me.TabPage1.ResumeLayout(False)
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.TabPage2.ResumeLayout(False)
CType(Me.DataGrid2, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DataSet1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DataTable1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DataTable2, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
For i = 0 To 20
DataTable1.Rows.Add(New Object() {"Row " & CStr(i)})
DataTable2.Rows.Add(New Object() {"Row " & CStr(i)})
Next
End Sub
End Class
''''''''''''''''''''''''''''''''''''''''''''
Here is a simple example of what I am talking about. Compile this, and run the program. Then
1. Click on TabPage2
2. Maximise
3. Click on TabPage1
4. You should see the datagrid of TabPage1 still has that scroll bar
PS. Assuming you are using 1024x768 or greater resolution