Area Selection by combo boxes

Discussion in 'Questions (Windows Mobile)' started by mozaharul, Apr 29, 2008.

  1. mozaharul

    mozaharul Active Member Licensed User

    Hi all,

    We want to select sepecif districts and sub districts as well under a selected division from the combo boxes used. And want to clear the value of district and sub district when there is a change in the division selection.

    The code works but with a error message.

    Please have a look and help.

    regards,
     

    Attached Files:

  2. Rioven

    Rioven Active Member Licensed User

    The SelectedIndex=-1 that triggers errors.
    You may consider assigning these combobox at index 0 to be "" blank or "-none-" then you can use or initialized selectedIndex=0.
     
  3. mozaharul

    mozaharul Active Member Licensed User

    Hi,

    The same code (cmbthana.selectedindex=-1) works for the sub districts(cmbthana combo box) without any error message, then wonder what is the cause for not working with the districts (cmbzilla combo box).


    regards,
     
  4. klaus

    klaus Expert Licensed User

    Hi,
    ComboBox1.SelectedIndex=-1 does not mean clear the selected text.
    You must clear the text of the selected item first.

    As soon as you have filled a ComboBox and selected an item then ComboBox1.SelectedIndex=-1 gives an error.

    ComboBox1.Clear does not clear the displayed text.
    Because, generally, a default selection is made.

    But why, after having initialized a combobox, not preselect the first item with ComboBox1.SelectedIndex=0 as the default, so the user has already one, and it avoids also your problem in a different way.

    I have joined a modified code that solves your problem, and shows better the solution than the text.

    For comparison, to show another way, I have replaced the
    If Then
    Else If
    End If etc

    by
    Select
    Case 0
    Case 1
    .
    .
    End Select

    Best regards
     

    Attached Files:

  5. mozaharul

    mozaharul Active Member Licensed User

    Hi klaus,

    Regards and thanks.

    Your help is appreciated.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice