CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2006
    Posts
    37

    Setting the values that can be displayed in the child combo box

    A tab has two combo boxes. The first one is the parent of the second one. The second one is the sub of the first one. It displays values for each item in the first combo box. That means each item in the first combo box has sub values in the second combo box.

    How do I prepare the coding or set anything else (in the properties) or sth so that for each item in the parent combo box, ONLY the sub values of that parent is displayed in the second combo box.

    The reason for this question is because for a parent item, the sub values of other parent items also appear in the second combo box.

  2. #2
    Join Date
    Nov 2006
    Posts
    37

    Checking the code

    In a form there are 5 tabs (Tab 1 to Tab 5). Tab 2 is the subcategory of Tab 1, Tab 3 is the sub of Tab 2, Tab 3 is the sub of Tab 4 and so on. From Tab 2 onwards, there are 2 combo boxes and 1 textbox. The second combo box of each tab displays the subvalues of each value of the first combo box. And the text box displays the description for the second combo box (this is also for each tab).

    By default, before any functions like editing, deleting, saving or adding new items, the first combo box of each tab will automatically display the value from the second combo box from the previous tab.(because each tab is the subcategory of the previous tab, so the first combo box of each tab from Tab 2 onwards will display the sub values of the previous tab)

    But now the problem I face is that from Tab 3 onwards the first combo box does not display the value from the second combo box of the previous tab. Even the text box does not display the description of the second combo box value. I do not know why.

    Please help me.

    Below is the coding from the beginning and Tab 2. The coding for Tab 3 onwards is exactly the same as Tab 2, except with different variable names.

    Is there anything wrong with the coding?

    Code:
    Imports System.Windows.Forms.DataGrid
    Imports System.Data.SqlClient
    
    Public Class InventoryMainForm
        Private CatCodeDesc As String
        Private CatCode As String
        Private WarehouseLocation As String
        Private Warehouse As String
        Private UOMCode As String
        Private subcatcode As String
        Private subcat1code As String
        Private subcat2code As String
        Private subcat3code As String
        Private AddNew As Boolean
        Dim DQcheck As New SqlCommand
        Dim DHcheck As New SqlDataAdapter
        Dim DScheck As New DataSet
        Dim Dvcheck As New DataView
        Private Sub InventoryMainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Try
                Me.CountryTableAdapter.Fill(Me.DsSales.country)
                Me.Inv_itemsubcategoryTableAdapter.Fill(Me.dsInventory.inv_itemsubcategory)
                Me.Inv_itemlocTableAdapter.Fill(Me.dsInventory.inv_itemloc)
                Me.Inv_itemuomTableAdapter.Fill(Me.dsInventory.inv_itemuom)
                Me.Inv_itemcategoryTableAdapter.Fill(Me.dsInventory.inv_itemcategory)
                Me.Inv_itemCat3TableAdapter.Fill(Me.dsInventory.inv_itemCat3)
                Me.Inv_itemCat4TableAdapter.Fill(Me.dsInventory.inv_itemCat4)
                Me.Inv_itemCat5TableAdapter.Fill(Me.dsInventory.inv_itemCat5)
            Catch ex As Exception
                MessageBox.Show(ex.Message, Me.Text + " FrmLoad", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End Try
        End Sub
    
    
     
        '=========Inventory Item Sub Category===========
        Private Sub subcatBindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subcatBindingNavigatorAddNewItem.Click
            subcatcode = cmbsubcatcode.SelectedValue
            cmbsubcatcode.Visible = False
            txtsubcat.Visible = True
            cmbitemcat.Text = ""
            txtsubcat.Text = ""
            txtsubcatdesc.Text = ""
            subcat(False)
            AddNew = True
            cmbitemcat.Focus()
        End Sub
    
        Private Sub subcat(ByVal check As Boolean)
    
            dgsubcategory.Enabled = check
            BindingNavigatorMoveFirstItem1.Enabled = check
            BindingNavigatorMoveLastItem1.Enabled = check
            BindingNavigatorMoveNextItem1.Enabled = check
            BindingNavigatorMovePreviousItem1.Enabled = check
            BindingNavigatorCountItem1.Enabled = check
            BindingNavigatorPositionItem1.Enabled = check
    
            subcatBindingNavigatorRefreshItem.Visible = check
            subcatBindingNavigatorAddNewItem.Visible = check
            subcatBindingNavigatorEditItem.Visible = check
            cmbsubcatcode.Visible = check
            txtitemcat.Visible = check
            If check = False Then
                check = True
                subcatBindingNavigatorDeleteItem.Text = "Cancel"
            Else
                check = False
                subcatBindingNavigatorDeleteItem.Text = "Delete"
            End If
    
            subcatBindingNavigatorSaveItem.Visible = check
            txtsubcat.Visible = check
            cmbitemcat.Visible = check
            txtsubcatdesc.Enabled = check
        End Sub
    
        Private Sub subcatBindingNavigatorEditItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subcatBindingNavigatorEditItem.Click
            If dgsubcategory.RowCount > 0 Then
                subcatcode = cmbsubcatcode.SelectedValue
                subcat(False)
                txtsubcat.Enabled = False
                cmbitemcat.Enabled = False
                cmbitemcat.Focus()
            Else
                MessageBox.Show("No record to edit.", Me.Text + " - Item Category Level 2", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End If
        End Sub
    
        Private Sub subcatBindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subcatBindingNavigatorDeleteItem.Click
            Try
                If dgsubcategory.RowCount > 0 Then
                    If subcatBindingNavigatorDeleteItem.Text = "Delete" Then
                        If MessageBox.Show("Are you sure to delete this record?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
                            gSQLstr = "SELECT COUNT(iim_subcat) FROM inv_itemmaster WHERE  iim_subcat = " & cSQL(cmbsubcatcode.Text) & ""
                            If gSQLcon.State = ConnectionState.Closed Then
                                gSQLcon.Open()
                            End If
                            DQcheck.Connection = gSQLcon
                            DQcheck.CommandText = gSQLstr
                            DHcheck.SelectCommand = DQcheck
                            DHcheck.Fill(DScheck, ("subcat_list"))
                            Dvcheck.Table = DScheck.Tables("subcat_list")
                            If Dvcheck.Table.Rows(0).Item(0) > 0 Then
                                MessageBox.Show("Record cannot be deleted!", Me.Text + " - Item Category Level 2", MessageBoxButtons.OK, MessageBoxIcon.Information)
                            Else
                                InvitemsubcategoryBindingSource.RemoveCurrent()
                                Inv_itemsubcategoryTableAdapter.Update(dsInventory)
                                MessageBox.Show("Record has been deleted.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information)
                            End If
                            DScheck.Clear()
                            gSQLcon.Close()
                        End If
                    Else
                        If AddNew = True Then
                            AddNew = False
                        End If
                        subcat(True)
                        txtsubcatdesc.Enabled = False
                        refreshsubcat()
                        cmbsubcatcode.SelectedValue = subcatcode
    
                    End If
                Else
                    MessageBox.Show("No record to delete.", Me.Text + " - Item Category Level 2", MessageBoxButtons.OK, MessageBoxIcon.Information)
                End If
    
            Catch ex As Exception
                MessageBox.Show(ex.Message, Me.Text + " - Item Category Level 2(Delete)", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End Try
        End Sub
    
        Private Sub subcatBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subcatBindingNavigatorSaveItem.Click
            Dim strmsg As String = ""
            Try
                If MessageBox.Show("Save Item?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
                    If AddNew = True Then
                        If txtsubcat.Text.Trim = "" Then
                            strmsg = strmsg & "Required field - Category Code." & vbCrLf
                        Else
                            gSQLstr = "SELECT COUNT(iis_code) FROM inv_itemsubcategory WHERE  iis_code = " & cSQL(txtsubcat.Text) & ""
                            If gSQLcon.State = ConnectionState.Closed Then
                                gSQLcon.Open()
                            End If
                            DQcheck.Connection = gSQLcon
                            DQcheck.CommandText = gSQLstr
                            DHcheck.SelectCommand = DQcheck
                            DHcheck.Fill(DScheck, ("subcat_list"))
                            Dvcheck.Table = DScheck.Tables("subcat_list")
    
    
                            If Dvcheck.Table.Rows(0).Item(0) > 0 Then
                                strmsg = strmsg & "Required field - Category Code already exits, please assign another Category Code!" & vbCrLf
                            End If
                            DScheck.Clear()
                            gSQLcon.Close()
                        End If
                    End If
                    If cmbitemcat.Text.Trim = "" Then
                        strmsg = strmsg & "Required field - Level 1 Category." & vbCrLf
                    End If
                    If txtsubcatdesc.Text.Trim = "" Then
                        strmsg = strmsg & "Required field - Description." & vbCrLf
                    End If
                    If strmsg = "" Then
                        If AddNew = True Then
                            dsInventory.inv_itemsubcategory.Addinv_itemsubcategoryRow(Trim(txtsubcat.Text), txtsubcatdesc.Text, cmbitemcat.Text)
                            Inv_itemsubcategoryTableAdapter.Update(dsInventory.inv_itemsubcategory)
                            Inv_itemsubcategoryTableAdapter.Fill(dsInventory.inv_itemsubcategory)
                            AddNew = False
                        Else
                            InvitemsubcategoryBindingSource.EndEdit()
                            Inv_itemsubcategoryTableAdapter.Update(dsInventory.inv_itemsubcategory)
                        End If
                        MessageBox.Show("Record saved", "Save", MessageBoxButtons.OK, MessageBoxIcon.None)
                        subcat(True)
                        cmbsubcatcode.Enabled = True
                        cmbsubcatcode.SelectedValue = subcatcode
                    Else
                        MessageBox.Show(strmsg, Me.Text + " -Item Category Level 2", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    End If
                End If
            Catch ex As Exception
                If ex.Message.Contains("Column 'iis_code, iis_itemcode' is constrained to be unique. ") = True Then
                    MessageBox.Show("The code already exits, please assign another code!", Me.Text + " - Item Category Level 2", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Exit Sub
                Else
                    MessageBox.Show(ex.Message, Me.Text + " - Item Category Level 2(Save)", MessageBoxButtons.OK, MessageBoxIcon.Information)
                End If
            End Try
        End Sub
    
        Private Sub subcatBindingNavigatorRefreshItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subcatBindingNavigatorRefreshItem.Click
            refreshsubcat()
        End Sub
    
        Private Sub refreshsubcat()
            Try
                Inv_itemsubcategoryTableAdapter.Fill(dsInventory.inv_itemsubcategory)
            Catch ex As Exception
                MessageBox.Show(ex.Message, Me.Text + " - Item Category Level 2(Refresh)", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End Try
        End Sub
    
        Private Sub btnclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclose.Click
            Me.Close()
        End Sub
    Last edited by HanneSThEGreaT; June 17th, 2008 at 05:34 AM. Reason: Added [CODE] [/CODE] Tags

  3. #3
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Setting the values that can be displayed in the child combo box

    Can you show us how exactly you are done this. You may be missing a simple one line of code.

  4. #4
    Join Date
    Nov 2006
    Posts
    37

    Re: Setting the values that can be displayed in the child combo box

    To be more specific I am developing a system which has five tabs on 1 form (Tab 1 to Tab 5). Tab 1 is the main tab with one combo box which displays values which also will be displayed in the first combo box of Tab 2. Tab 1 also has a text box that is a description of the value in that combo box.

    Tab 2 is the sub category of Tab 1. It has two combo boxes. The first combo box will display the value from Tab 1. The second combo box will display ONLY the sub values of each value from the first combo box(when selected). There is also a text box that will be disabled by default and only show the description of the second combo box value.

    Tab 3 till Tab 5 do the exact same thing like Tab 2, and these are the tabs that do not work like it is explained above. (Tab 3 to Tab 5).

    Below is the code for the beginning and also Tab 3. Is there anything wrong with it?

    Code:
    Imports System.Windows.Forms.DataGrid
    Imports System.Data.SqlClient
    
    Public Class InventoryMainForm
        Private CatCodeDesc As String
        Private CatCode As String
        Private subcatcode As String
        Private subcat1code As String
        Private subcat2code As String
        Private subcat3code As String
        Private AddNew As Boolean
        Dim DQcheck As New SqlCommand
        Dim DHcheck As New SqlDataAdapter
        Dim DScheck As New DataSet
        Dim Dvcheck As New DataView
    
    
        Private Sub InventoryMainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Try
                Me.CountryTableAdapter.Fill(Me.DsSales.country)
                Me.Inv_itemsubcategoryTableAdapter.Fill(Me.dsInventory.inv_itemsubcategory)
                Me.Inv_itemlocTableAdapter.Fill(Me.dsInventory.inv_itemloc)
                Me.Inv_itemuomTableAdapter.Fill(Me.dsInventory.inv_itemuom)
                Me.Inv_itemcategoryTableAdapter.Fill(Me.dsInventory.inv_itemcategory)
                Me.Inv_itemCat3TableAdapter.Fill(Me.dsInventory.inv_itemCat3)
                Me.Inv_itemCat4TableAdapter.Fill(Me.dsInventory.inv_itemCat4)
                Me.Inv_itemCat5TableAdapter.Fill(Me.dsInventory.inv_itemCat5)
            Catch ex As Exception
                MessageBox.Show(ex.Message, Me.Text + " FrmLoad", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End Try
        End Sub
    
    '=========Inventory Item Sub Category 1 ===========
    
        Private Sub subcat1BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subcat1BindingNavigatorAddNewItem.Click
            subcat1code = cmb1subcatcode.SelectedValue
            cmb1subcatcode.Visible = False
            txt1subcat.Visible = True
            cmb1itemcat.Text = ""
            txt1subcat.Text = ""
            txt1subcatdesc.Text = ""
            subcat1(False)
            AddNew = True
            cmb1itemcat.Focus()
        End Sub
    
        Private Sub subcat1(ByVal check As Boolean)
    
            dgsubcategory1.Enabled = check
            BindingNavigatorMoveFirstItem2.Enabled = check
            BindingNavigatorMoveLastItem2.Enabled = check
            BindingNavigatorMoveNextItem2.Enabled = check
            BindingNavigatorMovePreviousItem2.Enabled = check
            BindingNavigatorCountItem2.Enabled = check
            BindingNavigatorPositionItem2.Enabled = check
    
            subcat1BindingNavigatorRefreshItem.Visible = check
            subcat1BindingNavigatorAddNewItem.Visible = check
            subcat1BindingNavigatorEditItem.Visible = check
            cmb1subcatcode.Visible = check
            txt1itemcat.Visible = check
            If check = False Then
                check = True
                subcat1BindingNavigatorDeleteItem.Text = "Cancel"
            Else
                check = False
                subcat1BindingNavigatorDeleteItem.Text = "Delete"
            End If
    
            subcat1BindingNavigatorSaveItem.Visible = check
            txt1subcat.Visible = check
            cmb1itemcat.Visible = check
            txt1subcatdesc.Enabled = check
        End Sub
    
        Private Sub subcat1BindingNavigatorEditItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subcat1BindingNavigatorEditItem.Click
            If dgsubcategory1.RowCount > 0 Then
                subcat1code = cmb1subcatcode.SelectedValue
                subcat1(False)
                txt1subcat.Enabled = False
                cmb1itemcat.Enabled = False
                cmb1itemcat.Focus()
            Else
                MessageBox.Show("No record to edit.", Me.Text + " - Item Category Level 3", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End If
        End Sub
    
        Private Sub subcat1BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subcat1BindingNavigatorSaveItem.Click
            Dim strmsg As String = ""
            Try
                If MessageBox.Show("Save Item?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
                    If AddNew = True Then
                        If txt1subcat.Text.Trim = "" Then
                            strmsg = strmsg & "Required field - Category Code." & vbCrLf
                        Else
                            gSQLstr = "SELECT COUNT(ic3_code) FROM inv_itemCat3 WHERE  ic3_code = " & cSQL(txt1subcat.Text) & ""
                            If gSQLcon.State = ConnectionState.Closed Then
                                gSQLcon.Open()
                            End If
                            DQcheck.Connection = gSQLcon
                            DQcheck.CommandText = gSQLstr
                            DHcheck.SelectCommand = DQcheck
                            DHcheck.Fill(DScheck, ("subcat1_list"))
                            Dvcheck.Table = DScheck.Tables("subcat1_list")
    
    
                            If Dvcheck.Table.Rows(0).Item(0) > 0 Then
                                strmsg = strmsg & "Required field - Category Code already exits, please assign another Category Code!" & vbCrLf
                            End If
                            DScheck.Clear()
                            gSQLcon.Close()
                        End If
                    End If
                    If cmb1itemcat.Text.Trim = "" Then
                        strmsg = strmsg & "Required field - Level 3 Category." & vbCrLf
                    End If
                    If txt1subcatdesc.Text.Trim = "" Then
                        strmsg = strmsg & "Required field - Description." & vbCrLf
                    End If
                    If strmsg = "" Then
                        If AddNew = True Then
                            dsInventory.inv_itemCat3.Addinv_itemCat3Row(Trim(txt1subcat.Text), txt1subcatdesc.Text, cmb1itemcat.Text)
                            Inv_itemCat3TableAdapter.Update(dsInventory.inv_itemCat3)
                            Inv_itemCat3TableAdapter.Fill(dsInventory.inv_itemCat3)
                            AddNew = False
                        Else
                            InvitemCat3BindingSource.EndEdit()
                            Inv_itemCat3TableAdapter.Update(dsInventory.inv_itemCat3)
                        End If
                        MessageBox.Show("Record saved", "Save", MessageBoxButtons.OK, MessageBoxIcon.None)
                        subcat1(True)
                        cmb1subcatcode.Enabled = True
                        cmb1subcatcode.SelectedValue = subcat1code
                    Else
                        MessageBox.Show(strmsg, Me.Text + " -Item Category Level 3", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    End If
                End If
            Catch ex As Exception
                If ex.Message.Contains("Column 'ic3_code, ic3_itemcode' is constrained to be unique. ") = True Then
                    MessageBox.Show("The code already exits, please assign another code!", Me.Text + " - Item Category Level 3", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Exit Sub
                Else
                    MessageBox.Show(ex.Message, Me.Text + " - Item Category Level 3(Save)", MessageBoxButtons.OK, MessageBoxIcon.Information)
                End If
            End Try
        End Sub
    
        Private Sub subcat1BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subcat1BindingNavigatorDeleteItem.Click
            Try
                If dgsubcategory1.RowCount > 0 Then
                    If subcat1BindingNavigatorDeleteItem.Text = "Delete" Then
                        If MessageBox.Show("Are you sure to delete this record?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
                            gSQLstr = "SELECT COUNT(iim_subcat1) FROM inv_itemmaster WHERE  iim_subcat1 = " & cSQL(cmb1subcatcode.Text) & ""
                            If gSQLcon.State = ConnectionState.Closed Then
                                gSQLcon.Open()
                            End If
                            DQcheck.Connection = gSQLcon
                            DQcheck.CommandText = gSQLstr
                            DHcheck.SelectCommand = DQcheck
                            DHcheck.Fill(DScheck, ("subcat1_list"))
                            Dvcheck.Table = DScheck.Tables("subcat1_list")
                            If Dvcheck.Table.Rows(0).Item(0) > 0 Then
                                MessageBox.Show("Record cannot be deleted!", Me.Text + " - Item Category Level 3", MessageBoxButtons.OK, MessageBoxIcon.Information)
                            Else
                                InvitemCat3BindingSource.RemoveCurrent()
                                Inv_itemCat3TableAdapter.Update(dsInventory)
                                MessageBox.Show("Record has been deleted.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information)
                            End If
                            DScheck.Clear()
                            gSQLcon.Close()
                        End If
                    Else
                        If AddNew = True Then
                            AddNew = False
                        End If
                        subcat1(True)
                        txt1subcatdesc.Enabled = False
                        refreshsubcat1()
                        cmb1subcatcode.SelectedValue = subcat1code
    
                    End If
                Else
                    MessageBox.Show("No record to delete.", Me.Text + " - Item Category Level 3", MessageBoxButtons.OK, MessageBoxIcon.Information)
                End If
    
            Catch ex As Exception
                MessageBox.Show(ex.Message, Me.Text + " - Item Category Level 3(Delete)", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End Try
        End Sub
    
        Private Sub subcat1BindingNavigatorRefreshItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subcat1BindingNavigatorRefreshItem.Click
            refreshsubcat1()
        End Sub
        Private Sub refreshsubcat1()
            Try
                Inv_itemCat3TableAdapter.Fill(dsInventory.inv_itemCat3)
            Catch ex As Exception
                MessageBox.Show(ex.Message, Me.Text + " - Item Category Level 3(Refresh)", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End Try
        End Sub
    Last edited by Shuja Ali; June 17th, 2008 at 03:56 AM. Reason: Added code tags

  5. #5
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Setting the values that can be displayed in the child combo box

    Going forward please use CODE tags when you post code.

    Coming to your question, I do not see any code written for Combo box. What you need to do is this:

    On Combox's SelectIndexChange event handler, you will need to either get the child values from the database or if you already have them in a dataset/datatable, you can use Select method on these to select only those values that are child of the item that has been selected in the parent combobox. Then bind the resulting datatable to the child combo box.

  6. #6
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Checking the code

    Quote Originally Posted by __gini2
    Is there anything wrong with the coding?
    Yes, without [CODE] Tags, your code is impossible to read.

    Next time add [CODE] Tags, like this:
    [CODE]
    'Insert Your Code In Here
    [/CODE]

  7. #7
    Join Date
    Dec 2003
    Location
    Northern Ireland
    Posts
    1,362

    Re: Checking the code

    I had to do something like that before - one combos items depended on the selection of the previous combo.

    I don't know exactly what your trying to achieve, but when the selection of one combo is changed, you need to set the datasource of all other child combos to nothing (except for the immediate child which you will rebind).

    Unless your database is massive, you could load everything into datatables then create a dataview and set the rowfilters - then bind the dataviews to the combos.
    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook


    0100 1101 0110 1001 0110 0011 0110 1000 0110 0001 0110 0101 0110 1100 0010 0000 0100 0101 0110 1100 0110 1100 0110 0101 0111 0010

  8. #8
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Checking the code

    @gini2
    Please avoid posting same question in different threads. I have merged the two threads.

  9. #9
    Join Date
    Nov 2006
    Posts
    37

    Re: Setting the values that can be displayed in the child combo box

    Thank You so much for your feedback, I understand what you have answered, but could you provide me with an algorithm or coding so that I can better understand what you mean

  10. #10
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Setting the values that can be displayed in the child combo box

    You will have to write your own code. Following are the steps:

    1. Handle the Parent Combo Box's SelectedIndexChange Event.
    2. In the event handler, get all the values from the database for the Child Combo Box using the selected item of the parent combo box as the criteria.
    3. Bind / Load the values in to the child combo box.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured