تم اجرءا بعض التعديل
اولا قتل الكائن DataGrideView بعد الانتهاء فقد كنت مستعجل
وايضا تغيير الكود الذي في حدث النقر كالتالي :
واضافة الاجراء التالي :
وهذا للاختصار والتقليل من الشوشرة
في الحدث للزر Sample يمكن اضافة الامر التالي
اولا قتل الكائن DataGrideView بعد الانتهاء فقد كنت مستعجل
PHP كود :
Dim row As DataGridViewRow = New DataGridViewRow
Try
TextBox1.Text = "Employy"
TextBox2.Text = "Id"
row.CreateCells(DataGridView1)
row.Cells(0).Value = "id"
row.Cells(1).Value = "Integer"
DataGridView1.Rows.Add(row)
row = New DataGridViewRow
row.CreateCells(DataGridView1)
row.Cells(0).Value = "FirstName"
row.Cells(1).Value = "String"
DataGridView1.Rows.Add(row)
row = New DataGridViewRow
row.CreateCells(DataGridView1)
row.Cells(0).Value = "Age"
row.Cells(1).Value = "Date"
DataGridView1.Rows.Add(row)
Catch ex As Exception
Finally
row.Dispose()
End Try
وايضا تغيير الكود الذي في حدث النقر كالتالي :
PHP كود :
Addtext("Public Class TB_" & TextBox1.Text)
Addtext("Inherits DbGo")
Addtext(" ")
For Each row As DataGridViewRow In DataGridView1.Rows
If row.Cells(0).Value <> "" Then
Addtext("Private " & "_" & row.Cells(0).Value & " As " & row.Cells(1).Value)
End If
Next
Addtext(" ")
Addtext("Private ID_Key As String =""" & TextBox2.Text & """")
Addtext("Private TableName As String =""" & TextBox1.Text & """")
Addtext(" " & vbCrLf)
For Each row As DataGridViewRow In DataGridView1.Rows
If row.Cells(0).Value <> "" Then
Addtext("Public Property " & TextBox1.Text & "_" & row.Cells(0).Value & " As " & row.Cells(1).Value)
Addtext("Get", True)
Addtext(" Return _" & row.Cells(0).Value, True)
Addtext("End Get", True)
Addtext("Set(value As" & row.Cells(1).Value & ")", True)
Addtext(" _" & row.Cells(0).Value & "= value", True)
Addtext("End Set", True)
Addtext("End Property")
Addtext(" ")
End If
Next
RichTextBox1.AppendText("End Class")
Panel1.Visible = False
واضافة الاجراء التالي :
PHP كود :
Private Sub Addtext(str As String, Optional tab As Boolean = False)
If tab = True Then
RichTextBox1.AppendText(vbTab & str & vbCrLf)
Else
RichTextBox1.AppendText(str & vbCrLf)
End If
End Sub
وهذا للاختصار والتقليل من الشوشرة
في الحدث للزر Sample يمكن اضافة الامر التالي
PHP كود :
DataGridView1.Rows.Clear()
