???? ??? ??????? ???? ????? ??? ????? ???
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 ???? ??????? ???????:
- ?? ?????? ArrayList.
- ????? ?????? ????? ?? ?? ?????? ???????? ??? 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
?????? ???? ?????
- ?? Visual Basic2005 ?? ?? Visual Basic .NET ????? ????? ???? ????? Windows. ??? ????? Form1 ???? ???????.
- ?? ??????? ??????? ???? ??? ????? ??? ?????? ??? ??? ???????.
- ??????? ????? ?? 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
- ????? ???? ????????? ???????? Class1.vb ??? ?? ??????? ??? "???? ???????".
- ????? ???? ???? DataGrid ??? Form1. ??? ???? ???? DataGrid ??????? ????? ????? ????? ???????.
- ????? ????? ????? ???? ?? ??? Form1 ??? ?? ????? ??????? ??????.
- ????? ??????? Text Button1 ??? ??????.
- ????? ??????? Text Button2 ??? ??????.
- ????? ??????? Text Button3 ??? ?????.
- ????? ??????? Text Button4 ??? ???.
- ?? ?????? ????????? ???????? ??????? ??? ??? Form1:
Private cManager As CurrencyManager
Private al as New ArrayList()
- ?? ???? ???????? ???????? ??????? ?? ????? 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
- ?? ???? ???????? ???????? ??????? ??? ????? 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
- ?????? ??????? ???????.
- ???? ??? ?? ????? ??? ???????? ??? ?????? ?????? DataGrid. ???? ??? ????? ????? ??? ???????? ??? ???? ?? ???.
??????? ???? ????? ?? ???
????? ????? ???? ?? ??? ????? ??? ????. accessors ??????? (??? ???) ??????. ???? ???? ?? ?????? ???? ????? ???? ???.
????
ArrayList ?????? ???? ??????? ???????:
- ????? ????? ??? Class1.vb ?????? ??????? ?? ?????? ??
Public Class guitar
'...
End Class
??????:
Public Structure guitar
'...
End Structure
- ????? ?? ?????? ?????? ?????? ??? ???? ?? ?????? ?? ???? ?? 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
(http://support.microsoft.com/kb/316302/en-us/
)