????? ??? ???? ???? DataGrid ArrayList ?? ???????? ?? ????? ???????? 2005 Visual Basic ?? Visual Basic .NET

?????? ????????? ?????? ?????????
???? ???????: 316302 - ??? ???????? ???? ????? ????? ??? ???????.
?????? ??? ????? Microsoft Visual C# .NET ?? ??? ???????? ???? 316303.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ???? ????? ??? ????? ??? ArrayList ???????? ??? ???? ???? DataGrid. ?????? ????? ?? Microsoft Windows ????? ?? ???? ???? DataGrid ???? ??? ??????? ?????? ????? ????? ??????? ??????? ?????? ?????? DataGrid.

???????

???? ??????? ??????? ??????? ?????? ??? ????? ?????? ???????? ?????? ? ??? ??????? ????????:
  • Microsoft Visual Basic 2005 ?? Microsoft Visual Basic .NET
????? ??? ??????? ??? ??????? ??? ???????? ???????:
  • ?????? ??????? Visual Basic

????? ?????

??? ?? ???? ??? ???? ???? ??? ???? ???? accessors ???????. ??? ?? ???? ?? ????? ??? ??? ?????? ????? ? ????? ????? ??????. ????? ??? ????? ????????? ?? ??? ??????? ????? ????? (???? ??? ???? ???.) ?? ????? ????? ???? ??????? ???? ??? ???????.
Public Class guitar
    Private m_make As String
    Private m_model As String
    Private m_year As Short

    Public Sub New(ByVal make, ByRef model, ByVal year)
        m_make = make
        m_model = model
        m_year = year
    End Sub
    Public Property make() As String
        Get
            Return m_make
        End Get
        Set(ByVal Value As String)
            m_make = Value
        End Set
    End Property
    
End Class
				

????? ?????? ????? ??? ArrayList

????? ?????? ???????? ??? ArrayList ???? ??????? ???????:
  1. ?? ?????? ArrayList.
  2. ????? ?????? ????? ?? ?? ?????? ???????? ??? ArrayList.
Private al as New Arraylist()

al.Add(New guitar("Gibson", "Les Paul", 1958))
al.Add(New guitar("Fender", "Jazz Bass", 1964))
al.Add(New guitar("Guild", "Bluesbird", 1971))
				

??? ?? ArrayList DataGrid

??? ?? ??? ????? ????????(SSP) ArrayList ????? ??????? DataSource ????? ?????? DataGridArrayList. ??? ????? ??????? ???????? ?? ???? ?????? DataGrid ????? ??? ????? ?????? ???? accessors ??????? ?? ??????.
DataGrid1.DataSource = al
				

???? ????? ??????? ?? ArrayList

????? ??????? CurrencyManager ???????? ArrayList. ?????? ????? ?? ?????? CurrencyManagerBindingContext ???? ?????? (?? ??? ??????? ArrayList).
Private cManager As CurrencyManager

cManager = CType(DataGrid1.BindingContext(al), CurrencyManager)
				
????? ??? CurrencyManager ????? ???? ????? ?????? ????? ??? ????? ArrayList. ?? ???? ????? ??? ?? ??? ?? ???? ?????? ??????, ????? ??????? ?????? ?????? DataGrid.
'Move forward one element.
cManager.Position += 1
'Move back one element.
cManager.Position -= 1
'Move to the beginning.
cManager.Position = 0
'Move to the end.
cManager.Position = al.Count - 1
				

?????? ???? ?????

  1. ?? Visual Basic2005 ?? ?? Visual Basic .NET ????? ????? ???? ????? Windows. ??? ????? Form1 ???? ???????.
  2. ?? ??????? ??????? ???? ??? ????? ??? ?????? ??? ??? ???????.
  3. ??????? ????? ?? Class1.vb ???????:
    Public Class guitar
        Private m_make As String
        Private m_model As String
        Private m_year As Short
    
        Public Sub New(ByVal make, ByRef model, ByVal year)
            m_make = make
            m_model = model
            m_year = year
        End Sub
        Public Property make() As String
            Get
                Return m_make
            End Get
            Set(ByVal Value As String)
                m_make = Value
            End Set
        End Property
        Public Property model() As String
            Get
                Return m_model
            End Get
            Set(ByVal Value As String)
                m_model = Value
            End Set
        End Property
        Public Property year() As Short
            Get
                Return m_year
            End Get
            Set(ByVal Value As Short)
                m_year = Value
            End Set
        End Property
    End Class
    					
  4. ????? ???? ????????? ???????? Class1.vb ??? ?? ??????? ??? "???? ???????".
  5. ????? ???? ???? DataGrid ??? Form1. ??? ???? ???? DataGrid ??????? ????? ????? ????? ???????.
  6. ????? ????? ????? ???? ?? ??? Form1 ??? ?? ????? ??????? ??????.
  7. ????? ??????? Text Button1 ??? ??????.
  8. ????? ??????? Text Button2 ??? ??????.
  9. ????? ??????? Text Button3 ??? ?????.
  10. ????? ??????? Text Button4 ??? ???.
  11. ?? ?????? ????????? ???????? ??????? ??? ??? Form1:
    Private cManager As CurrencyManager
    Private al as New ArrayList()
    					
  12. ?? ???? ???????? ???????? ??????? ?? ????? Form1_Load:
    al.Add(New guitar("Gibson", "Les Paul", 1958))
    al.Add(New guitar("Fender", "Jazz Bass", 1964))
    al.Add(New guitar("Guild", "Bluesbird", 1971))
    				
    cManager = CType(DataGrid1.BindingContext(al), CurrencyManager)
    	
    DataGrid1.DataSource = al
    					
  13. ?? ???? ???????? ???????? ??????? ??? ????? Form_Load:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            cManager.Position += 1
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            cManager.Position -= 1
        End Sub
    
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            cManager.Position = 0
        End Sub
    
        Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            cManager.Position = al.Count - 1
        End Sub
    					
  14. ?????? ??????? ???????.
  15. ???? ??? ?? ????? ??? ???????? ??? ?????? ?????? DataGrid. ???? ??? ????? ????? ??? ???????? ??? ???? ?? ???.

??????? ???? ????? ?? ???

????? ????? ???? ?? ??? ????? ??? ????. accessors ??????? (??? ???) ??????. ???? ???? ?? ?????? ???? ????? ???? ???.

???? ArrayList ?????? ???? ??????? ???????:
  1. ????? ????? ??? Class1.vb ?????? ??????? ?? ?????? ??
    Public Class guitar
    '...
    End Class
    					
    ??????:
    Public Structure guitar
    '...
    End Structure
    					
  2. ????? ?? ?????? ?????? ?????? ??? ???? ?? ?????? ?? ???? ?? ArrayList ????.

?????

????? ?? ?????????? ???? ??????? "???????? ??? Windows ????? ????????" ?? Visual Studio .NET Online ???????.

???????

???? ???????: 316302 - ????? ??? ??????: 15/?? ??????/1427 - ??????: 3.3
????? ???
  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
????? ??????: 
kbmt kbvs2005swept kbvs2005applies kbhowtomaster KB316302 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????316302

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com