我已经将mshflexgrid用于我的vb.net程序。但是当我尝试构建时它显示错误,因为vb.net不支持mshflexgrid。请检查我的代码和&告诉我如何在datagridview中做同样的事情? Datagridview不支持相同的代码。那么请你告诉我应该为它写些什么?请检查我的代码。
Public Function refreshMyForm() As Boolean con = New ADODB.Connection con.Open("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SUIMT") rst = New ADODB.Recordset
With rst
.Open("Select Uname, Upass, smad_cuser, smad_duser, smad_cpass, smad_apermi, smad_soall, smsm_cay, smsm_day, smsm_csess, smsm_delses, smsm_cdep, smsm_deldep, smsm_cetyp, smsm_deletyp, smsm_csub, smsm_delsub, smsm_admi, smsm_deladmi, smsm_admirep, smsm_stuinfo, smsm_delstuinfo, smsm_sstuinfo, smsm_stuinfrep, smsm_cstures, smsm_delstures, smsm_sturesrep, smsm_rsrep, sma_cmi, sma_dmi, sma_mirep, sma_cbalsht, sma_delbsht, sma_balsrep from Permission_info", con, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
Mshgrid1.DataSource = rst
Mshgrid1.set_TextMatrix(0, 0, "USER NAME")
Mshgrid1.set_TextMatrix(0, 1, "PASSWORD")
Mshgrid1.set_TextMatrix(0, 2, "CREATE USER")
Mshgrid1.set_TextMatrix(0, 3, "DELETE USER")
Mshgrid1.set_TextMatrix(0, 4, "CHANGE PASSWORD")
Mshgrid1.set_TextMatrix(0, 5, "ASSIGN PERMISSION")
Mshgrid1.set_TextMatrix(0, 6, "SHOW ALL USERS")
Mshgrid1.set_TextMatrix(0, 7, "CREATE ACADEMIC YEAR")
Mshgrid1.set_TextMatrix(0, 8, "DELETE ACADEMIC YEAR")
Mshgrid1.set_TextMatrix(0, 9, "CREATE SESSION")
Mshgrid1.set_TextMatrix(0, 10, "DELETE SESSION")
Mshgrid1.set_TextMatrix(0, 11, "CREATE DEPARTMENT")
Mshgrid1.set_TextMatrix(0, 12, "DELETE DEPARTMENT")
Mshgrid1.set_TextMatrix(0, 13, "CREATE EXAM TYPE")
Mshgrid1.set_TextMatrix(0, 14, "DELETE EXAM TYPE")
Mshgrid1.set_TextMatrix(0, 15, "CREATE SUBJECT")
Mshgrid1.set_TextMatrix(0, 16, "DELETE SUBJECT")
Mshgrid1.set_TextMatrix(0, 17, "ADMISSION")
Mshgrid1.set_TextMatrix(0, 18, "DELETE ADMISSION")
Mshgrid1.set_TextMatrix(0, 19, "ADMISSION REPORT")
Mshgrid1.set_TextMatrix(0, 20, "STUDENT INFORMATION")
Mshgrid1.set_TextMatrix(0, 21, "DELETE STUDENT INFORMATION")
Mshgrid1.set_TextMatrix(0, 22, "SEARCH STUDENT INFORMATION")
Mshgrid1.set_TextMatrix(0, 23, "STUDENT INFORMATION REPORT")
Mshgrid1.set_TextMatrix(0, 24, "CREATE STUDENT RESULT")
Mshgrid1.set_TextMatrix(0, 25, "DELETE STUDENT RESULT")
Mshgrid1.set_TextMatrix(0, 26, "STUDENT RESULT REPORT")
Mshgrid1.set_TextMatrix(0, 27, "RESULT SHEET REPORT")
Mshgrid1.set_TextMatrix(0, 28, "CREATE MONTHLY INSTALLMENT")
Mshgrid1.set_TextMatrix(0, 29, "DELETE MONTHLY INSTALLMENT")
Mshgrid1.set_TextMatrix(0, 30, "MONTHLY INSTALLMENT REPORT")
Mshgrid1.set_TextMatrix(0, 31, "CREATE BALANCE SHEET")
Mshgrid1.set_TextMatrix(0, 32, "DELETE BALANCE SHEET")
Mshgrid1.set_TextMatrix(0, 33, "BALANCE SHEET REPORT")
Mshgrid1.set_ColWidth(0, 3200)
Mshgrid1.set_ColWidth(1, 3200)
Mshgrid1.set_ColWidth(2, 3200)
Mshgrid1.set_ColWidth(3, 3200)
Mshgrid1.set_ColWidth(4, 3200)
Mshgrid1.set_ColWidth(5, 3200)
Mshgrid1.set_ColWidth(6, 3200)
Mshgrid1.set_ColWidth(7, 3200)
Mshgrid1.set_ColWidth(8, 3200)
Mshgrid1.set_ColWidth(9, 3200)
Mshgrid1.set_ColWidth(10, 3200)
Mshgrid1.set_ColWidth(11, 3200)
Mshgrid1.set_ColWidth(12, 3200)
Mshgrid1.set_ColWidth(13, 3200)
Mshgrid1.set_ColWidth(14, 3200)
Mshgrid1.set_ColWidth(15, 3200)
Mshgrid1.set_ColWidth(16, 3200)
Mshgrid1.set_ColWidth(17, 3200)
Mshgrid1.set_ColWidth(18, 3200)
Mshgrid1.set_ColWidth(19, 3200)
Mshgrid1.set_ColWidth(20, 3200)
Mshgrid1.set_ColWidth(21, 3200)
Mshgrid1.set_ColWidth(22, 3200)
Mshgrid1.set_ColWidth(23, 3200)
Mshgrid1.set_ColWidth(24, 3200)
Mshgrid1.set_ColWidth(25, 3200)
Mshgrid1.set_ColWidth(26, 3200)
Mshgrid1.set_ColWidth(27, 3200)
Mshgrid1.set_ColWidth(28, 3200)
Mshgrid1.set_ColWidth(29, 3200)
Mshgrid1.set_ColWidth(30, 3200)
Mshgrid1.set_ColWidth(31, 3200)
Mshgrid1.set_ColWidth(32, 3200)
Mshgrid1.set_ColWidth(33, 3200)
.Close()
refreshMyForm = True
Exit Function
End With
End Function
............................................... .........................................
Private Sub cmbdbsdt_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbdbsdt.Leave On Error Resume Next rst = New ADODB.Recordset With rst .Open("Select row_num, soincom, amouoinco, soexp, amouoexp, bsdate from Bal_sheet where bsdate = '" & cmbdbsdt.Text & "'", con, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic) Mshgrid3.DataSource = rst
Mshgrid3.set_TextMatrix(0, 0, "ROW NUMBER")
Mshgrid3.set_TextMatrix(0, 1, "SOURCE OF INCOME")
Mshgrid3.set_TextMatrix(0, 2, "AMOUNT OF INCOME")
Mshgrid3.set_TextMatrix(0, 3, "SOURCE OF EXPENSE")
Mshgrid3.set_TextMatrix(0, 4, "AMOUNT OF EXPENSE")
Mshgrid3.set_TextMatrix(0, 5, "DATE")
Mshgrid3.set_ColWidth(0, 2500)
Mshgrid3.set_ColWidth(1, 2500)
Mshgrid3.set_ColWidth(2, 2500)
Mshgrid3.set_ColWidth(3, 2500)
Mshgrid3.set_ColWidth(4, 2500)
Mshgrid3.set_ColWidth(5, 2500)
.Close()
End With
End Sub
请编辑我的代码&告诉我应该为datagridview写什么。
答案 0 :(得分:1)
对于您似乎直接从数据库填充的第一个网格,请查看以下文章:
How to: Bind Data to the Windows Forms DataGridView Control
对于您似乎手动填充的第二个网格,请查看以下文章:
Walkthrough: Creating an Unbound Windows Forms DataGridView Control
这两篇文章应该为您提供足够的信息以便开始使用,如果您遇到任何问题,请在此处提出更具体的问题,我相信有人会帮忙。