I have a datagrid which has five columns. i want the cell’s value selected by user. I am able to get the selected row index but not column index.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One way to get the column index of the current cell is to subclass DataGrid and add an extra dependency property:
This solution relies on the
CurrentCellChangedevent to update the index of the selected column whenever the current cell changes.This solution returns the same index for the same column regardless of any reordering of the columns. In other words, if one column has index 2, and you drag the column elsewhere in the grid, it will still have index 2.