2011-05-17 77 views
1

我正在开发一个VB.NET应用程序,我在其中使用DataGrid;由于版本的原因,我无法使用较新的DataGridView。但现在,当我尝试编译,我得到的错误:CurrencyManager在vb.NET中的替代?

Dim CM As New CurrencyManager(dgTable.BindingContext)

我能替换为这一行:

BC30002: Type 'CurrencyManager' is not defined.

上线它的错误?我在互联网上看过,既然我的应用程序应该是基于网络的,我不能使用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文件:

公共DSTableData作为新System.Data.DataSet中 公共DV作为新的数据视图

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 

回答

1

CurrencyManager是WinForms功能。
你不能(也不需要)在ASP.Net中使用它。