i have a datagrid that load the data from my database. in my datagrid, i also included the , so that i can checked or unchecked the row.
here is the picture.

here is my xaml.
<DataGrid AutoGenerateColumns="False" Height="258" HorizontalAlignment="Left" Margin="12,0,0,12"
Name="dataGrid1" VerticalAlignment="Bottom" Width="479" ItemsSource="{Binding data}"
AlternatingRowBackground="#FFC4B0B0">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding nCateogryID}" Header="No." IsReadOnly="True" Width="30" />
<DataGridTextColumn Binding="{Binding sCategoryDesc}" Header="Nama Kategori" IsReadOnly="True" Width="160" />
<DataGridTextColumn Binding="{Binding sCategoryItems}" Header="Keterangan Kategori" IsReadOnly="True" Width="170" />
<DataGridCheckBoxColumn Header="Checked?" />
</DataGrid.Columns>
</DataGrid>
May question is:
How can i know which data already checked whenever i hit the ‘Button’? I also do search on google, but found nothing.
i think like this. whenever i click ‘Button’, i will start to check for each row. how can i do it? any sample for that?
i also think to find another solution, how about using the event handler? thats mean whenever i click for the row and checked, i will trigger the event and check if is it checked or not. How can i do it?
For me, using the event handler is more achieveable because it’s much faster rather i have to checked, and press button. lets say if i have only 10 rows, that’s not a big problem. How about if i have 1000rows? if i check one by one, it will be troublesome. waste alot of time. any idea? thanks.
Or maybe use the datagrid_selectionchanged.
How can i check the checkbox has been checked or not?
because if we wait until user press button, then we check is checked or not, i think its a slow process. you have to check for each row. if my row only 10rows, maybe its okay. how about if i have 1000 rows need to check? thanks. 🙂
Here “EmpId” is checkbox name(control name) and i am using value of first cells for write. You can change the cell index as you want to use.