-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: Kishor
Message 4 in Discussion

Hi,
first Remove the code ComboBox1_Click as it is not needed.

1. In indimodify1_Load

        I assume u populated the dataset. after that u use this code to populate
combobox, instead of using for loop.

        Dim dv As DataView = dataset........DefaultView
        combobox1.DataSource = dv
        ' column to be displayed in combo
        combobox1.DisplayMember = "arabcountryname"
        ' column to be stored in database
        combobox1.ValueMember = "id_country"

        Me.ComboBox1.SelectedIndex = 0
        (as on form load  u dont know which country is selected)

2. ComboBox1_SelectionChangeCommitted

prepare sql as
        select timeid, cntnameng from timediff where countryname = '" &
combobox1.selectedText & "'"
or
        select timeid, cntnameng from timediff where  id_country  = " &
combobox1.selectedvalue

        I am assuming timeid as cityId and cntnameng as city Name

        Dim dv1 As DataView = dataset........DefaultView
        ComboBox2.DataSource = dv1
        ' column to be displayed in combo
        ComboBox2.DisplayMember = "cntnameng"
        ' column to be stored in database
        ComboBox2.ValueMember = "timeid"


        'This is for the Initialization city combo
        ComboBox2.SelectedIndex = 0

 and in this event only if you know the city

ComboBox2.Selectedvalue = "whatever val from u r database"


ok

This is just linking of combos... now where ever u want to show the country
and its associated city
set first Country combo
        ComboBox1.Selectedvalue =
and then city combo
        ComboBox2.Selectedvalue =




Bye
Kishor




Private Sub indimodify1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim str_12 As String = "select id_country,countryname from timediff where
timeid = " & time_iid & ""
'Dim str_12 As String = "select distinct id_country,arabcountryname from
timediff "
Dim sql_12 As New OleDbDataAdapter(str_12, coned)
Dim dst_12 As New DataSet()
Dim i_12 As Integer
sql_12.Fill(dst_12, "lister_12")
'Dim groupy As String
If dst_12.Tables("lister_12").Rows.Count > 0 Then
For i_12 = 0 To dst_12.Tables("lister_12").Rows.Count - 1
Dim nodpX_12 As String =
dst_12.Tables("lister_12").Rows(i_12).Item("countryname")
Me.ComboBox1.Items.Add(nodpX_12)
Next
End If
Me.ComboBox1.SelectedIndex = 0
End If
Dim str_128 As String = "select timeid, cntnameng from timediff where timeid
= " & time_iid & ""
Dim sql_128 As New OleDbDataAdapter(str_128, coned)
Dim dst_128 As New DataSet()
Dim i_128 As Integer
sql_128.Fill(dst_128, "lister_128")
'Dim groupy As String
If dst_128.Tables("lister_128").Rows.Count > 0 Then
For i_128 = 0 To dst_128.Tables("lister_128").Rows.Count - 1
Dim nodpX_128 As String =
dst_128.Tables("lister_128").Rows(i_128).Item("cntnameng")
Me.ComboBox2.Items.Add(nodpX_128)
Next
End If
Me.ComboBox2.SelectedIndex = 0
End sub
Private Sub ComboBox1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ComboBox1.Click
Dim str_12 As String = "select distinct id_country,countryname from timediff
"
Dim sql_12 As New OleDbDataAdapter(str_12, coned)
Dim dst_12 As New DataSet()
Dim i_12 As Integer
sql_12.Fill(dst_12, "lister_12")
'Dim groupy As String
If dst_12.Tables("lister_12").Rows.Count > 0 Then
For i_12 = 0 To dst_12.Tables("lister_12").Rows.Count - 1
Dim nodpX_12 As String =
dst_12.Tables("lister_12").Rows(i_12).Item("countryname")
Me.ComboBox1.Items.Add(nodpX_12)
Next
End If
End Sub
Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As Object, ByVal
e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted
Me.ComboBox2.Items.Clear()
Dim coun_name As String
coun_name = Me.ComboBox1.SelectedText
MsgBox(coun_name)

Dim str_128 As String = "select timeid, cntnameng from timediff where
countryname = '" & coun_name & "'"
Dim sql_128 As New OleDbDataAdapter(str_128, coned)
Dim dst_128 As New DataSet()
Dim i_128 As Integer
sql_128.Fill(dst_128, "lister_128")
'Dim groupy As String
If dst_128.Tables("lister_128").Rows.Count > 0 Then
For i_128 = 0 To dst_128.Tables("lister_128").Rows.Count - 1
Dim nodpX_128 As String =
dst_128.Tables("lister_128").Rows(i_128).Item("cntnameng")
Me.ComboBox2.Items.Add(nodpX_128)
Next
End If

End Sub

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your
E-mail Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On
the pre-addressed e-mail message that opens, simply click "Send". Your
e-mail address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]



-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to