|
こんなんでどうですかね?
int col = DataGrid.SelectedCells[0].ColumnIndex;
int row = DataGrid.SelectedCells[0].RowIndex;
while ( 0 <= col && 0 <= row && DataGrid[col,row].Selected == true ) {
col--;
row--;
}
col++;
row++;
if ( col != 0 && DataGrid[col-1,row].Selected == true ) {
for ( col--; 0 <= col && DataGrid[col,row].Selected == true; col-- ) ;
col++;
}
if ( row != 0 && DataGrid[col,row-1].Selected == true ) {
for ( row--; 0 <= row && DataGrid[col,row].Selected == true; row-- ) ;
row++;
}
ごめんなさい。未確認ですが、たぶんいけるんじゃないかと…
|