DataGridComboBoxColumn selectionChanged Problem

Mar 12, 2010 at 12:54 PM

hello friends

i am new to WPF and developing browse based WPF page

i have a DataGridComboBoxColumn column in DataGrid (WpfToolkit control)
now i want Selectedindexchanged for the combobox.

i have implemeted it in following way

<WpfToolkit:DataGridComboBoxColumn 
ScrollViewer.CanContentScroll="True" 
CellStyle="{StaticResource LeftAlignedCellStyle}" 
Header="Schedule" x:Name="CmbSchedule" Width="250" 
SelectedValueBinding="{Binding SCHEDULE1}" 
DisplayMemberPath="SNAME" SelectedValuePath="SCODE"  >
<WpfToolkit:DataGridComboBoxColumn.EditingElementStyle>
   <Style TargetType="{x:Type ComboBox}" >
      <EventSetter Event="SelectionChanged" 
                Handler="CmbSchedule_SelectionChanged" />
    </Style> 
 </WpfToolkit:DataGridComboBoxColumn.EditingElementStyle>         

</WpfToolkit:DataGridComboBoxColumn>


In Code Behind file

Private Sub CmbSchedule_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs)
        Dim accb As ComboBox = CType(sender, ComboBox)
        Dim ItemName As ComboBox = CType(CmbItems.ItemsSource, ComboBox)
        If (GV1.Items.IndexOf(GV1.SelectedItem) > -1 AndAlso Not IsDBNull(GV1.Items(GV1.Items.IndexOf(GV1.SelectedItem))("SCHEDULE1"))) Then
            If (accb.SelectedValue = "Y") Then
                If (GV1.Items(GV1.Items.IndexOf(GV1.SelectedItem))("ITEMCODE").ToString = String.Empty) Then
                    MessageBox.Show("Please Select Item Before Schedule Settings", "Data Error", MessageBoxButton.OK, MessageBoxImage.Information)
                    Return
                Else
                    FillSchedule(GV1.Items(GV1.Items.IndexOf(GV1.SelectedItem))("ITEMCODE").ToString)
                End If
            End If
        End If

    End Sub


Now what my problem is the event is raised multiple times
when i click on cell which contains this combobox, this event is raised multiple times
I want this event to be raised only when i change value in combobox

Plz help me 
Regards
vipul