Solved

VB.net - SelectionChangeCommitted event problem

Posted on 2007-04-10
11
1,201 Views
Last Modified: 2012-05-05
I've a problem with the SelectionChangeCommitted event

The event is triggered when user does change, but when checking the ComboBox.text after even, the text value is the same as previous - it doesn't change.

I'm using SelectionChangeCommitted so event is only triggered when user does change to combo box, and not when any code changes the combo

Came across this http://weblogs.asp.net/grobinson/archive/2005/09/21/425711.aspx but not really sure what its saying to do

Thanks
0
Comment
Question by:rwallacej
  • 6
  • 5
11 Comments
 
LVL 67

Expert Comment

by:sirbounty
Comment Utility
Hello rwallacej,
What's in the event code now?
I'm using this currently in a project I'm working on and don't see that behavior...

~sirbounty
0
 

Author Comment

by:rwallacej
Comment Utility
   Private Sub ComboBox_MP_SelectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox_MP.SelectionChangeCommitted
        MessageBox.Show("THE NEW VALUE IS: " & ComboBox_MP.Text)
    End Sub

displays
1) THE NEW VALUE IS: [the original value]

2) the combo box the changes

the messagebox appears before the combobox changes
0
 
LVL 67

Expert Comment

by:sirbounty
Comment Utility
You'll want to use:

 MessageBox.Show("THE NEW VALUE IS: " & ComboBox_MP.SelectedValue)

(or .SelectedText)
0
 

Author Comment

by:rwallacej
Comment Utility
still the same :-(
0
 

Author Comment

by:rwallacej
Comment Utility
form2.designer.vb

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form2
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.ComboBox_MP = New System.Windows.Forms.ComboBox
        Me.SuspendLayout()
        '
        'ComboBox_MP
        '
        Me.ComboBox_MP.FormattingEnabled = True
        Me.ComboBox_MP.Items.AddRange(New Object() {"None", "Motor driven", "Turbine driven"})
        Me.ComboBox_MP.Location = New System.Drawing.Point(12, 12)
        Me.ComboBox_MP.Name = "ComboBox_MP"
        Me.ComboBox_MP.Size = New System.Drawing.Size(109, 21)
        Me.ComboBox_MP.TabIndex = 6
        '
        'Form2
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Controls.Add(Me.ComboBox_MP)
        Me.Name = "Form2"
        Me.Text = "Form2"
        Me.ResumeLayout(False)

    End Sub
    Friend WithEvents ComboBox_MP As System.Windows.Forms.ComboBox
End Class
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:rwallacej
Comment Utility
Public Class Form2

    Private Sub ComboBox_MP_SelectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox_MP.SelectionChangeCommitted
        MessageBox.Show("THE NEW VALUE IS: " & ComboBox_MP.SelectedText)

    End Sub
End Class
0
 
LVL 67

Expert Comment

by:sirbounty
Comment Utility
Did you try selectedValue?
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
Comment Utility
Or you might try
MessageBox.Show(ComboBox_MP.Items.Item(ComboBox_MP.SelectedIndex))
0
 

Author Comment

by:rwallacej
Comment Utility
yes, selectedvalue always gives "" (blank)
0
 

Author Comment

by:rwallacej
Comment Utility
MessageBox.Show(ComboBox_MP.Items.Item(ComboBox_MP.SelectedIndex))
works
0
 
LVL 67

Expert Comment

by:sirbounty
Comment Utility
Odd - but glad it does! :^)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now