0% found this document useful (0 votes)
12 views7 pages

Add DataRow To DataGrid

The document is a Visual Basic .NET application that creates a Windows Forms interface for data binding using a DataGrid and a DataTable. It allows users to add new rows to the DataGrid by entering data into text boxes and clicking the 'Add' button. The application initializes a DataSet and DataTable with predefined columns and provides functionality to display and add data to the grid.

Uploaded by

keysha.shanum123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views7 pages

Add DataRow To DataGrid

The document is a Visual Basic .NET application that creates a Windows Forms interface for data binding using a DataGrid and a DataTable. It allows users to add new rows to the DataGrid by entering data into text boxes and clicking the 'Add' button. The application initializes a DataSet and DataTable with predefined columns and provides functionality to display and add data to the grid.

Uploaded by

keysha.shanum123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Add DataRow to DataGrid

Imports System
Imports [Link]
Imports [Link]
Imports [Link]

public class DataBinding


public Shared Sub Main
[Link](New Form1)
End Sub
End class

Public Class Form1


Inherits [Link]

Public Sub New()


[Link]()

InitializeComponent()

End Sub

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)


If disposing Then
If Not (components Is Nothing) Then
[Link]()
End If
End If
[Link](disposing)
End Sub

Private components As [Link]


Friend WithEvents DataSet1 As [Link]
Friend WithEvents DataTable1 As [Link]
Friend WithEvents DataColumn1 As [Link]
Friend WithEvents DataColumn2 As [Link]
Friend WithEvents DataColumn3 As [Link]
Friend WithEvents DataColumn4 As [Link]
Friend WithEvents DataColumn5 As [Link]
Friend WithEvents DataColumn6 As [Link]
Friend WithEvents DataGrid1 As [Link]
Friend WithEvents Label1 As [Link]
Friend WithEvents TextBox1 As [Link]
Friend WithEvents Label2 As [Link]
Friend WithEvents TextBox2 As [Link]
Friend WithEvents Label3 As [Link]
Friend WithEvents TextBox3 As [Link]
Friend WithEvents Label4 As [Link]
Friend WithEvents TextBox4 As [Link]
Friend WithEvents Label5 As [Link]
Friend WithEvents TextBox5 As [Link]
Friend WithEvents Label6 As [Link]
Friend WithEvents TextBox6 As [Link]
Friend WithEvents Button1 As [Link]
Friend WithEvents Button2 As [Link]
<[Link]()> Private Sub InitializeComponent
()
Me.DataSet1 = New [Link]
Me.DataTable1 = New [Link]
Me.DataColumn1 = New [Link]
Me.DataColumn2 = New [Link]
Me.DataColumn3 = New [Link]
Me.DataColumn4 = New [Link]
Me.DataColumn5 = New [Link]
Me.DataColumn6 = New [Link]
Me.DataGrid1 = New [Link]
Me.Label1 = New [Link]
Me.TextBox1 = New [Link]
Me.Label2 = New [Link]
Me.TextBox2 = New [Link]
Me.Label3 = New [Link]
Me.TextBox3 = New [Link]
Me.Label4 = New [Link]
Me.TextBox4 = New [Link]
Me.Label5 = New [Link]
Me.TextBox5 = New [Link]
Me.Label6 = New [Link]
Me.TextBox6 = New [Link]
Me.Button1 = New [Link]
Me.Button2 = New [Link]
CType(Me.DataSet1, [Link]).BeginInit
()
CType(Me.DataTable1, [Link]).BeginIn
it()
CType(Me.DataGrid1, [Link]).BeginIni
t()
[Link]()
'
'DataSet1
'
[Link] = "NewDataSet"
[Link] = New [Link]("zh-CN")
[Link](New [Link]() {Me.DataTable1
})
'
'DataTable1
'
[Link](New [Link]() {[Link]
lumn1, Me.DataColumn2, Me.DataColumn3, Me.DataColumn4, Me.DataColumn5, [Link]
Column6})
[Link] = "Table1"
'
'DataColumn1
'
[Link] = "A"
[Link] = "A"
'
'DataColumn2
'
[Link] = "B"
[Link] = GetType(System.Int32)
'
'DataColumn3
'
[Link] = "C"
[Link] = "C"
[Link] = GetType(System.Int32)
'
'DataColumn4
'
[Link] = "D"
[Link] = GetType(System.Int32)
'
'DataColumn5
'
[Link] = "E"
[Link] = GetType(System.Int32)
'
'DataColumn6
'
[Link] = "F"
'
'DataGrid1
'
[Link] = ""
[Link] = Me.DataTable1
[Link] = [Link]
[Link] = [Link]
[Link] = New [Link](0, 0)
[Link] = "DataGrid1"
[Link] = New [Link](488, 216)
[Link] = 0
'
'Label1
'
[Link] = New [Link](24, 224)
[Link] = "Label1"
[Link] = New [Link](48, 24)
[Link] = 1
[Link] = "A"
'
'TextBox1
'
[Link] = New [Link](64, 224)
[Link] = "TextBox1"
[Link] = New [Link](64, 20)
[Link] = 2
[Link] = ""
'
'Label2
'
[Link] = New [Link](168, 224)
[Link] = "Label2"
[Link] = New [Link](48, 24)
[Link] = 3
[Link] = "B"
'
'TextBox2
'
[Link] = New [Link](216, 224)
[Link] = "TextBox2"
[Link] = New [Link](72, 20)
[Link] = 4
[Link] = ""
'
'Label3
'
[Link] = New [Link](24, 256)
[Link] = "Label3"
[Link] = New [Link](48, 24)
[Link] = 5
[Link] = "C"
'
'TextBox3
'
[Link] = New [Link](64, 256)
[Link] = "TextBox3"
[Link] = New [Link](64, 20)
[Link] = 6
[Link] = ""
'
'Label4
'
[Link] = New [Link](168, 256)
[Link] = "Label4"
[Link] = New [Link](48, 24)
[Link] = 7
[Link] = "D"
'
'TextBox4
'
[Link] = New [Link](216, 256)
[Link] = "TextBox4"
[Link] = New [Link](72, 20)
[Link] = 8
[Link] = ""
'
'Label5
'
[Link] = New [Link](24, 288)
[Link] = "Label5"
[Link] = New [Link](48, 24)
[Link] = 9
[Link] = "E"
'
'TextBox5
'
[Link] = New [Link](64, 288)
[Link] = "TextBox5"
[Link] = New [Link](64, 20)
[Link] = 10
[Link] = ""
'
'Label6
'
[Link] = New [Link](144, 288)
[Link] = "Label6"
[Link] = New [Link](80, 24)
[Link] = 11
[Link] = "F"
'
'TextBox6
'
[Link] = New [Link](216, 288)
[Link] = "TextBox6"
[Link] = New [Link](72, 20)
[Link] = 12
[Link] = ""
'
'Button1
'
[Link] = New [Link](328, 224)
[Link] = "Button1"
[Link] = New [Link](72, 24)
[Link] = 13
[Link] = "Display"
'
'Button2
'
[Link] = New [Link](328, 264)
[Link] = "Button2"
[Link] = New [Link](72, 24)
[Link] = 14
[Link] = "Add"
'
'Form1
'
[Link] = New [Link](5, 13)
[Link] = New [Link](488, 318)
[Link](Me.Button2)
[Link](Me.Button1)
[Link](Me.TextBox6)
[Link](Me.Label6)
[Link](Me.TextBox5)
[Link](Me.Label5)
[Link](Me.TextBox4)
[Link](Me.Label4)
[Link](Me.TextBox3)
[Link](Me.Label3)
[Link](Me.TextBox2)
[Link](Me.Label2)
[Link](Me.TextBox1)
[Link](Me.Label1)
[Link](Me.DataGrid1)
CType(Me.DataSet1, [Link]).EndInit()
CType(Me.DataTable1, [Link]).EndInit
()
CType(Me.DataGrid1, [Link]).EndInit(
)
[Link](False)

End Sub

Private Sub Button1_Click(ByVal sender As [Link], ByVal e As System


.EventArgs) Handles [Link]
Dim row1 As DataRow
row1 = [Link]
row1("A") = "Tom"
row1("B") = 121
row1("C") = 145
row1("D") = 134
row1("E") = 127
row1("F") = "032158"
[Link](row1)

row1 = [Link]
row1("A") = "John"
row1("B") = 95
row1("C") = 102
row1("D") = 94
row1("E") = 85
row1("F") = "032176"
[Link](row1)

row1 = [Link]
row1("A") = "Alice"
row1("B") = 137
row1("C") = 96
row1("D") = 125
row1("E") = 94
row1("F") = "032152"
[Link](row1)

row1 = [Link]
row1("A") = "Jack"
row1("B") = 98
row1("C") = 134
row1("D") = 87
row1("E") = 124
row1("F") = "032156"
[Link](row1)
End Sub

Private Sub Button2_Click(ByVal sender As [Link], ByVal e As System


.EventArgs) Handles [Link]
Dim row1 As DataRow
row1 = [Link]
row1("A") = [Link]
row1("B") = 123
row1("C") = 123
row1("D") = 123
row1("E") = 123
row1("F") = [Link]
[Link](row1)
[Link]()
End Sub
End Class

You might also like