我正在开发一个使用DataGrid的VB.NET应用程序;由于版本的原因,我无法使用较新的DataGridView。但是现在当我尝试编译它时,我得到了错误:
BC30002:类型'CurrencyManager'不是 定义
在线错误:
Dim CM As New 的CurrencyManager(dgTable.BindingContext)
我可以用这条线替换什么?我在互联网上看到,由于我的应用程序应该是基于Web的,我不能使用Windows命名空间。我认为我要求的是一个非常简单的解决方案,但我是一个非常新的VB程序员。我的更多代码如下。
Global.vb文件:
Imports System.Data
Imports System.Data.OLEDB
Imports System.Web
Imports System.Math
Imports system.data.SqlClient
Imports System.Windows.Forms
Imports System.Windows.Forms.CurrencyManager
Namespace GlobalFunctions
Public Class GlobalF
Public Shared Function GlobalF_Load(ByVal dgTable As DataGrid)
Dim dv As New DataView
Dim ds As New DataSet
Dim CM As New CurrencyManager(dgTable.BindingContext)
dv = New DataView(ds.Tables(0))
dgTable.DataSource = dv
dv.Sort = "Part No."
'CM = (System.Windows.Forms.CurrencyManager)
dgTable.BindingContext([dv])
Dim sender As New sender()
dv.ListChanged += New ListChangedEventHandler(dv_ListChangedEvent)
End Function
Public Shared Function btnFind_Click(ByVal sender As Object, ByVal e As EventArgs)
If (txtFind.Text = "") Then
Response.write("Enter some criteria to find.")
txtFind.Focus()
Else
Dim i As Int
i = dv.Find(txtFind.Text)
If (i > dv.Table.Rows.Count Or i < 0) Then
Response.Write("Record Not found")
Else
CM.Position = i
End If
End If
End Function
Private Shared Function dv_ListChangedEvent(ByVal sender As Object, ByVal e As ListChangedEventArgs) Handles btnFind.ListChanged
If (dv.Sort.Substring((dv.Sort.Length - 4), 4) = "DESC") Then
lblFind.Text = "Enter Search Criteria " + dv.Sort.Substring(0, dv.Sort.Length - 5)
Else
lblFind.Text = "Enter Search Criteria " + dv.Sort
End If
End Function
和我的ASPX文件:
Public DSTableData As New System.Data.DataSet Public dv As New DataView
Sub Main()
'------------------------- Query database and get arrays for the chart and bind query results to datagrid ----------------------------------------
If check1.Checked Then
DSTableData = GlobalFunctions.GlobalF.FillSparePartsTable(1)
Else
DSTableData = GlobalFunctions.GlobalF.FillSparePartsTable(0)
End If
'dv = DataView(DSTableData(0))
dgTable.DataSource = DSTableData
dgTable.DataBind()
GlobalFunctions.GlobalF.GlobalF_Load(dgTable)
End Sub
答案 0 :(得分:1)
CurrencyManager
是一个WinForms功能
你不能(也不需要)在ASP.Net中使用它。