Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF ComboBox LostFocus not working as expected, What do to?

$
0
0

Hi,

I put a ComboBox on my WPF forms named cboTest with a TextBox named txtTest

and what I want is, when the cbox LostFocus, Get the value selected and make over check

so I create a LostFocus Event like this

Private Sub cboTest_LostFocus(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles cboTest.LostFocus 'My code If(cboTesT.Text = "1") Then

txtTest.text="Your boss 1"

Else

txtTest.Text ="Your boss unknow"

End If End Sub

At this stage everything work as expected

But I replace my code with this on, It work strangely

Private Sub cboTest_LostFocus(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles cboTest.LostFocus 'My code MessageBox.Show(cboTest.Text) End Sub


when I use Keyboarb to select the combobox and change its value, it work perfectly.

But When I use the mouse to select it, the MessageBox shows continuously especially when I just click on the ComboBox, (it show two times, sure after click OK two times)  and three times when I succeed to finally change the value, again when I click on the TextBox and When I want to close the WPF Forms.

Please, someone can help me fix this issue, so that the MessgeBox only show after the user have selected a value (using his mouse)????

PS : I've already see all the related post, but they just do nothing about showing the value throw MessageBox

Thanks a lot in advance for your Help



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>