Dear Xceed WPF datagrid experts,
I am struggling with the WPF datagrid cell background changes. I used the following code but in result it shows something else,
If I select one cell to change the BG, say rowIndex=2, colIndex=3, and the in the spread in the same column (colIndex:3) multiple randomly row got marked. where I wanted only selected.
please update me if write any wrong code.
System.Collections.Generic.IList<SelectionCellRange> selItems = dataSpreadView.OrdersGrid.SelectedCellRanges;
foreach (var selectionCellRange in selItems)
{
int colIndex = selectionCellRange.ColumnRange.StartIndex;
int rowIndex = selectionCellRange.ItemRange.StartIndex;
DataRow dr = dataSpreadView.OrdersGrid.GetContainerFromIndex(rowIndex) as DataRow;
dr.Cells[colIndex].Background = System.Windows.Media.Brushes.Red;
}