dimanche 10 mai 2015

Datagridview combobox selected items getting changed on scroll

I have a data-grid and in each row have combobox wit multiple values in it. I select one combobox value in one row and then after selecting 5-6 row combobox values previous selected values i.e 1st or 2nd row combobox values getting changed automatically...

Show me your code than I could check it to see what might be the problem.

Source:-

 <DataGrid Foreground="Transparent" Background="Transparent" x:Name="dgvbat1" ItemsSource="{Binding}" Padding="12" HorizontalAlignment="Left" Margin="220.687,36,0,0" VerticalAlignment="Top" Height="230" Width="888" BorderBrush="Black" BorderThickness="1" Grid.Column="2" AutoGenerateColumns="False" IsReadOnly="False">
                    <DataGrid.Columns>
                        <DataGridTextColumn  Header="SLNO" Binding="{Binding Path=SLNO}" />
                        <DataGridTextColumn Header="Name Of Players" Binding="{Binding Path=Name Of Players}"/>
                        <DataGridTextColumn Header="KSCA UID" Binding="{Binding Path=KSCA UID}" />
                        <DataGridTemplateColumn  Header="Dismissal">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>

                                    <ComboBox Name="DismissalA" SelectionChanged="DismissalA_SelectionChanged" >
                                        <ComboBoxItem>Caught</ComboBoxItem>
                                        <ComboBoxItem>Bowled</ComboBoxItem>
                                        <ComboBoxItem>LBW</ComboBoxItem>
                                        <ComboBoxItem>Run Out</ComboBoxItem>
                                        <ComboBoxItem>CAUGHT AND BOWLED</ComboBoxItem>
                                        <ComboBoxItem>DNB</ComboBoxItem>
                                        <ComboBoxItem>Stumped</ComboBoxItem>
                                        <ComboBoxItem>Hit Wicket</ComboBoxItem>
                                        <ComboBoxItem>Handled The Ball</ComboBoxItem>
                                        <ComboBoxItem>Timed Out</ComboBoxItem>
                                        <ComboBoxItem>ObstructingTheField</ComboBoxItem>
                                        <ComboBoxItem>Not Out</ComboBoxItem>
                                    </ComboBox>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                        <DataGridTextColumn Header="Runs" Binding="{Binding Path=Runs}" />
                        <DataGridTextColumn Header="Mins" Binding="{Binding Path=Mins}" />
                        <DataGridTextColumn Header="Balls" Binding="{Binding Path=Balls}"/>
                        <DataGridTextColumn Header="Fours" Binding="{Binding Path=Fours}"/>
                        <DataGridTextColumn Header="Sixes" Binding="{Binding Path=Sixes}"/>

                    </DataGrid.Columns>
                </DataGrid>

Code:-

public void DismissalA_SelectionChanged(object sender, SelectionChangedEventArgs e)

{
            dismissalvaluesA.indexA = dgvbat1.SelectedIndex;
            dismissalvaluesA.dismissaltypeA[dismissalvaluesA.indexA] = (e.AddedItems[0] as ComboBoxItem).Content as string;

}

Aucun commentaire:

Enregistrer un commentaire