CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2019
    Location
    Michigan
    Posts
    35

    [RESOLVED] Get the SelectedIndexChanged events of a combobox to fire Visual Studio 2012

    Hello again.

    Same project as in a previous post: https://forums.codeguru.com/showthre...al-Studio-2012

    Name:  Form3 example.jpg
Views: 376
Size:  22.3 KB

    If the user manually types in a value (letter A-Z) I want the SelectedIndexChanged event of that combo box to fire.
    Based upon the value in the combo box, a label changes it's text value:

    Code:
    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
            If ConfigSet = True Then Exit Sub
    
            If Rnd_Letters.Checked = False Then CalcNumLetters()
    
            Check_Defaults()
            OKToolStripMenuItem.Enabled = True
            SAVEToolStripMenuItem.Enabled = True
        End Sub
    
    Private Sub CalcNumLetters()
    
            Select Case True
    
                Case ComboBox1.Text > ComboBox2.Text
                    Label10.Text = "Backward"
                    TextBox1.Text = Str(Math.Abs(Asc(ComboBox1.Text) - Asc(ComboBox2.Text)) + 1)
    
                Case ComboBox2.Text > ComboBox1.Text
                    Label10.Text = "Foreword"
                    TextBox1.Text = Str(Math.Abs(Asc(ComboBox2.Text) - Asc(ComboBox1.Text)) + 1)
    
            End Select
    
            TextBox1.Enabled = False
    
        End Sub

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,494

    Re: Get the SelectedIndexChanged events of a combobox to fire Visual Studio 2012

    Have you put a breakpoint inside the ComboBox1_SelectedIndexChanged handler to see if it fires at all?

  3. #3
    Join Date
    May 2019
    Location
    Michigan
    Posts
    35

    Re: Get the SelectedIndexChanged events of a combobox to fire Visual Studio 2012

    Yes. I tried other events too. I can't find anything useful.

  4. #4
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,097

    Re: Get the SelectedIndexChanged events of a combobox to fire Visual Studio 2012

    Quote Originally Posted by oldGMtireman View Post
    Yes. I tried other events too. I can't find anything useful.
    You were asked not to try "other events"!
    Did you set the breakpoint inside the ComboBox1_SelectedIndexChanged handler to see if it fires?
    Victor Nijegorodov

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,494

    Re: Get the SelectedIndexChanged events of a combobox to fire Visual Studio 2012

    Post the code where the ComboBox1_SelectedIndexChanged event handler is wired up to the control.

  6. #6
    Join Date
    May 2019
    Location
    Michigan
    Posts
    35

    Re: Get the SelectedIndexChanged events of a combobox to fire Visual Studio 2012

    Where was I asked not to try "other events"?
    I answered the second question.

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,494

    Re: Get the SelectedIndexChanged events of a combobox to fire Visual Studio 2012

    Quote Originally Posted by oldGMtireman View Post
    Where was I asked not to try "other events"?
    I answered the second question.
    Does it matter? Keep in mind that folks here are trying to help you.

    There isn't much to intercepting the select change event. You need the body of the handler and you need the code that wires up the handler to the control. If you have this then you should be able to put a breakpoint inside the handler, and have it hit when you perform the action that causes the event to fire. Once you have that, then you can continue to step through the code inside the handler to make sure it does what you think it does.

    There's really only 3 things in play:
    1. The user action you perform doesn't fire the event you are handling.
    2. The event handler isn't wired up properly.
    3. The code inside the handler doesn't work, making you believe the event isn't firing.

    All of this can be sorted out by debugging.

Tags for this Thread

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