Results 1 to 6 of 6

Thread: [RESOLVED] listbox click event

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Location
    vbforums
    Posts
    809

    Resolved [RESOLVED] listbox click event

    How can I achieve List Box click event .. whereas I have three listboxes , list1, list2, list3



    With List1
    .AddItem "apple"

    .AddItem "orange"

    .AddItem "banana"

    End With



    Now when in list1 apple is clicked list2 show show apple grades like {Grade A, B and so on} and then when list2 GradeA is clicked list3 should show now apple types like {type1, type 2 and so on}

    is it possible to achieve this by codes only not by .ini file

    please need help

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: listbox click event

    My preferred way is to store the data in a db table. Yours might look like this:

    Code:
    TypeFruit        GradeFruit    NameFruit
    2                   C                Apple
    3                   B                Apple
    1                   F                Apple
    1                   A                Banana
    Then, when you click on list 1 you can display all grades in List2, and then when you click on list2 all types will be shown in list3
    Example, if Apple is selected in list1, list2 would show C, B and F. Then if you click on, say B, in list2, list3 would show type 3.
    etc.

  3. #3
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: listbox click event

    Private Sub Form_Load()
    With List1
    .AddItem "apple"

    .AddItem "orange"

    .AddItem "banana"

    End With
    End Sub

    Private Sub List1_Click()
    If List1.Text = "apple" Then
    List2.Clear
    List2.AddItem "apple mix"
    List2.AddItem "apple fruites"
    ElseIf List1.Text = "orange" Then
    List2.Clear
    List2.AddItem "arange mixed fruite juice"
    List2.AddItem "arange juice extra"
    ElseIf List1.Text = "banana" Then
    List2.Clear
    List2.AddItem "banna extra"
    List2.AddItem "banna light"
    End If

    End Sub

    Private Sub List2_Click()
    If List2.Text = "apple mix" Then
    List3.Clear
    List3.AddItem "apple mix 2014"
    List3.AddItem "apple fruites 2015"
    ElseIf List2.Text = "apple fruites" Then
    List3.Clear
    List3.AddItem "apple fruites 2014"
    List3.AddItem "apple fruites 2015"
    ElseIf List2.Text = "arange mixed fruite juice" Then
    List3.Clear
    List3.AddItem "arange mixed fruite juice mega"
    List3.AddItem "arange mixed fruite juice light"
    ElseIf List2.Text = "arange juice extra" Then
    List3.Clear
    List3.AddItem "arange mixed fruite juice 3333333333333333333333333333"
    List3.AddItem "arange mixed fruite juice aaaaaaaaaaaaaaaaaaaaaa"
    ElseIf List2.Text = "banna extra" Then
    List3.Clear
    List3.AddItem "banna extra 204"
    List3.AddItem "banna light 3333333"
    ElseIf List2.Text = "banna light" Then
    List3.Clear
    List3.AddItem "banna extra 4444444444444"
    List3.AddItem "banna light 11111111111"
    End If
    End Sub



    good luck just work your way from there rename it to grades and add also use select case preferd

    u can use select case also
    Last edited by ladoo; Jul 27th, 2013 at 08:08 AM.

  4. #4
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: listbox click event

    As you can see, you CAN do it all in code, but depending upon how many fruits (including grades and types of each), it could get pretty lengthy.

    See the small attached example using a database with MSACCESS 2007.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Location
    vbforums
    Posts
    809

    Re: listbox click event

    thanks I got it .. Resolved

  6. #6
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: listbox click event

    Quote Originally Posted by janu View Post
    thanks I got it .. Resolved
    From your post no one can tell who you were thanking, nor which post you were responding to.
    Also future Googlers, may be interested in how it was resolved (which solution you chose).
    I reckon it is . . . . . (I am still trying to think of a word that is not rude or personal) to close a thread and share no information.

    Rob

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