Hi Cor,
I tried your code, and yes it does work. But I'm using a DataSet that is
bound to an ODBC data source. Try the code that I have below, and you'll see
what I mean.
--- BEGINNING OF CODE SEGMENT ---
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 TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents DataSet1 As System.Data.DataSet
Friend WithEvents DataTable1 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.TextBox1 = New System.Windows.Forms.TextBox
Me.TabPage2 = New System.Windows.Forms.TabPage
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.DataSet1 = New System.Data.DataSet
Me.DataTable1 = New System.Data.DataTable
Me.DataColumn1 = New System.Data.DataColumn
Me.DataColumn2 = New System.Data.DataColumn
Me.TabControl1.SuspendLayout()
Me.TabPage1.SuspendLayout()
Me.TabPage2.SuspendLayout()
CType(Me.DataSet1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.DataTable1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'TabControl1
'
Me.TabControl1.Controls.Add(Me.TabPage1)
Me.TabControl1.Controls.Add(Me.TabPage2)
Me.TabControl1.Location = New System.Drawing.Point(24, 40)
Me.TabControl1.Name = "TabControl1"
Me.TabControl1.SelectedIndex = 0
Me.TabControl1.Size = New System.Drawing.Size(248, 208)
Me.TabControl1.TabIndex = 0
'
'TabPage1
'
Me.TabPage1.Controls.Add(Me.TextBox1)
Me.TabPage1.Location = New System.Drawing.Point(4, 22)
Me.TabPage1.Name = "TabPage1"
Me.TabPage1.Size = New System.Drawing.Size(240, 182)
Me.TabPage1.TabIndex = 0
Me.TabPage1.Text = "TabPage1"
'
'TextBox1
'
Me.TextBox1.DataBindings.Add(New System.Windows.Forms.Binding("Text",
Me.DataSet1, "Table1.Column1"))
Me.TextBox1.Location = New System.Drawing.Point(80, 56)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "TextBox1"
'
'TabPage2
'
Me.TabPage2.Controls.Add(Me.TextBox2)
Me.TabPage2.Location = New System.Drawing.Point(4, 22)
Me.TabPage2.Name = "TabPage2"
Me.TabPage2.Size = New System.Drawing.Size(240, 182)
Me.TabPage2.TabIndex = 1
Me.TabPage2.Text = "TabPage2"
'
'TextBox2
'
Me.TextBox2.DataBindings.Add(New System.Windows.Forms.Binding("Text",
Me.DataSet1, "Table1.Column2"))
Me.TextBox2.Location = New System.Drawing.Point(120, 80)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.TabIndex = 0
Me.TextBox2.Text = "TextBox2"
'
'DataSet1
'
Me.DataSet1.DataSetName = "NewDataSet"
Me.DataSet1.Locale = New System.Globalization.CultureInfo("en-US")
Me.DataSet1.Tables.AddRange(New System.Data.DataTable() {Me.DataTable1})
'
'DataTable1
'
Me.DataTable1.Columns.AddRange(New System.Data.DataColumn() {Me.DataColumn1,
Me.DataColumn2})
Me.DataTable1.TableName = "Table1"
'
'DataColumn1
'
Me.DataColumn1.ColumnName = "Column1"
'
'DataColumn2
'
Me.DataColumn2.ColumnName = "Column2"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.TabControl1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.TabControl1.ResumeLayout(False)
Me.TabPage1.ResumeLayout(False)
Me.TabPage2.ResumeLayout(False)
CType(Me.DataSet1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DataTable1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Dim bool As Boolean
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
dim a as DataRow
DIm b(1) as String
b(0) = "dummy1"
b(1) = "dummy2"
a = dataset1.Tables(0).Rows.Add(b)
msgbox(textbox2.Text)
End Sub
End Class
---- END OF CODE SEGMENT ----
Thanks,
Andrew