0
DataGrids를 사용하여 WPF 프로젝트에서 작업 중입니다. 사용자가 원하는만큼 행을 선택하거나 단일 셀만 선택할 수있게하려고합니다. 즉 셀 범위를 선택 해제 할 수 있습니다. 그러나 나는 그 일을 할 수 없었다.DataGrid에서만 복수 행 또는 단일 셀 선택
이것이 가능합니까?
나는 다음과 같은 코드를 시도 :
public MyDataGrid : DataGrid
{
public ExtendedDataGrid()
{
SelectionMode = DataGridSelectionMode.Extended;
SelectionUnit = DataGridSelectionUnit.CellOrRowHeader;
this.SelectedCellsChanged += new SelectedCellsChangedEventHandler(MyDataGrid_SelectedCellsChanged);
}
void MyDataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
{
if (this.SelectedCells.Count > 1)
{
DataGridCellInfo currentCell = this.CurrentCell;
this.SelectedCells.Clear();
this.CurrentCell = currentCell;
}
}
을하지만이 코드 나 전체 행을 선택하는 것을 허용하지 않습니다.
그래서 원하는만큼 많은 행을 선택할 수 있지만 사용자가 셀 범위를 선택하지 못하도록하는 방법이 있습니까 ??
미리 감사드립니다.