Combo value not getting changed
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 6 of 6

Thread: Combo value not getting changed

Threaded View

  1. #1
    Join Date
    Mar 2009

    Question Combo value not getting changed

    Hi All,

    My aim is not to fire selection changed event when combo value is changed through code.I have written following code:

    <Window x:Class="TestCombo.Window1" xmlns=""
    Title="Window1" Height="300" Width="300">

    <ComboBox Width="100" IsTextSearchEnabled="False" VerticalAlignment="Center" IsEditable="True" HorizontalAlignment="Center" Name="cmbTest" SelectionChanged="cmbTest_SelectionChanged"/>
    <Button Grid.Row="1" Click="Button_Click" Content="Set Combo Value"/>

    Code Behind

    Public Window1()

    private void cmbTest_SelectionChanged(object sender, SelectionChangedEventArgs e)
    MessageBox.Show("Selection Changed");

    private void Button_Click(object sender, RoutedEventArgs e)
    cmbTest.Text = "25";

    Problem Scenario
    1) Run the application select 100 from combo drop down and you will see "Selection Changed" messagebox coming up.
    2) Now click the button "Set Combo Value" see combo text now changed to 25.
    3) Now again try to set combo value to "100" from drop down and notice interestingly nothing will happen and combo would still remain at value 25.

    How can i avoid this strange behavior?

    Plese suggest.

    Last edited by anurodhora; June 3rd, 2009 at 05:18 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)