Solved

VB.net - SelectionChangeCommitted event problem

Posted on 2007-04-10
11
1,245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18882573
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
ID: 18882625
   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
ID: 18882657
You'll want to use:

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

(or .SelectedText)
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:rwallacej
ID: 18882708
still the same :-(
0
 

Author Comment

by:rwallacej
ID: 18882717
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
 

Author Comment

by:rwallacej
ID: 18882721
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
ID: 18882776
Did you try selectedValue?
0
 
LVL 67

Accepted Solution

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

Author Comment

by:rwallacej
ID: 18882791
yes, selectedvalue always gives "" (blank)
0
 

Author Comment

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

Expert Comment

by:sirbounty
ID: 18882832
Odd - but glad it does! :^)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

759 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