 |
|
Event ของ Combobox ครับ.... ผมใช้ VS-2005 + Window Apps.... |
|
 |
|
|
 |
 |
|
ปกติเราดับเบิ้ลคลิกที่ Event มันก็ Gen ให้อยู่แล้วน่ะครับ น่าจะ SelectedIndexChanged
|
 |
 |
 |
 |
Date :
2010-09-23 14:36:15 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
SelectedIndexChanged
|
 |
 |
 |
 |
Date :
2010-09-23 14:42:32 |
By :
noptalent |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทีแรกก็ใช้ครับ มันขึ้นให้ครั้งเดียว ต้องโหลดหรือเคลียร์ใหม่ถึงจะเลือกแล้วขึ้นให้...
|
 |
 |
 |
 |
Date :
2010-09-23 15:25:56 |
By :
t-monroe |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ดูโค้ดหน่อยดีกว่า แบบนี้เดี๋ยวงงกันหมด
|
 |
 |
 |
 |
Date :
2010-09-23 21:04:45 |
By :
noptalent |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมก้อใช้ selectIndexChanged แต่ว่ามาน error ครับ
ผมใช้แบบ dim TypeId as string = Combobox.selectvalue
|
 |
 |
 |
 |
Date :
2010-10-17 01:09:31 |
By :
ibankza11 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Private Sub Customers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If F_Connection(conn) = False Then Exit Sub
Call_province()
call_amphur()
End Sub
Private Sub Call_province()
If F_Connection(conn) = False Then Exit Sub
ds.Tables.Clear()
Try
ls_sql = "SELECT provinceid,des FROM tblprovince "
ls_sql &= "ORDER BY des"
da = New SqlDataAdapter(ls_sql, conn)
da.Fill(ds, "province")
If ds.Tables("province").Rows.Count <> 0 Then
With cb_province
.DataSource = ds.Tables("province")
.DisplayMember = "des"
.ValueMember = "provinceid"
End With
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub call_amphur()
ds.Tables.Clear()
Try
ls_sql = "SELECT amphur_id,des FROM tblamphur "
If cb_province.ValueMember = "" Then
Exit Sub
Else
ls_sql &= "where province_id = '" & CStr(cb_province.SelectedValue) & "'"
ls_sql &= "ORDER BY des"
da = New SqlDataAdapter(ls_sql, conn)
da.Fill(ds, "tblamphur")
If ds.Tables("tblamphur").Rows.Count <> 0 Then
With cb_amphur
.DataSource = ds.Tables("tblamphur")
.DisplayMember = "des"
.ValueMember = "amphur_id"
End With
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub cb_province_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cb_province.SelectedValueChanged
call_amphur()
End Sub
|
 |
 |
 |
 |
Date :
2012-02-10 16:00:39 |
By :
หนึ่ง ณ มทรก |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณ
|
 |
 |
 |
 |
Date :
2012-04-11 01:17:20 |
By :
pisansri |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|