 |
|
ขอคำแนะนำ ด้วยครับ รายละเอียด ด้านในครับ [มือใหม่หัดเขียน] |
|
 |
|
|
 |
 |
|
ก็เกือบได้แล้วน่ะครับ เอา เพียงแค่สร้าง DataSource ใส่ใน Event ก็ได้เลยครับ
Go to : ASP.NET DropDownlist and DataBinding
ตัวอย่างการสร้าง DataSource ครับ
หรือจาก List ทีเป็น Array
Code (VB.NET)
Public Class Country
Public Property Name() As String
Get
Return m_Name
End Get
Set
m_Name = Value
End Set
End Property
Private m_Name As String
Public Property Cities() As IList(Of City)
Get
Return m_Cities
End Get
Set
m_Cities = Value
End Set
End Property
Private m_Cities As IList(Of City)
Public Sub New(_name As String)
Cities = New List(Of City)()
Name = _name
End Sub
End Class
Dim countries As New List(Of Country)() From { _
New Country("USA"), _
New Country("Itly"), _
New Country("Iran"), _
New Country("UK") _
}
bindingSource1.DataSource = countries
comboBox1.DataSource = bindingSource1.DataSource
comboBox1.DisplayMember = "Name"
comboBox1.ValueMember = "Name"
|
 |
 |
 |
 |
Date :
2011-07-20 21:29:07 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อีกตัว
Code (VB.NET)
Dim comboBox As New ComboBox
Dim daysOfWeek As String() = _
New String() {"Monday", "Tuesday", "Wednesday", _
"Thursday", "Friday", "Saturday", _
"Sunday"}
With comboBox
.DataSource = daysOfWeek
.Location = New System.Drawing.Point(12, 12)
.Name = "comboBox"
.Size = New System.Drawing.Size(166, 21)
.DropDownStyle = ComboBoxStyle.DropDownList
End With
|
 |
 |
 |
 |
Date :
2011-07-20 21:30:44 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|