void SetMultiSelectMode(GridView view, DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode multiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect) {
	view.OptionsSelection.MultiSelectMode = multiSelectMode;
}

string GetSelectedRows(GridView view) {
	//출처 : DevExpress - "Demo Center 19.2" / WinForms Demos / Data Grid and Editors / UI CUSTOMIZATION / Cell Selection 
    string ret = "";
    int rowIndex = -1;
    if(view.OptionsSelection.MultiSelectMode != GridMultiSelectMode.CellSelect) {
        foreach(int i in gridView1.GetSelectedRows()) {
            DataRow row = gridView1.GetDataRow(i);
            if(ret != "") ret += "\r\n";
            ret += string.Format("{2}: {0} (#{1})", row["CompanyName"], i, Properties.Resources.CompanyName);
        }
    }
    else {
        foreach(GridCell cell in view.GetSelectedCells()) {
            if(rowIndex != cell.RowHandle) {
                if(ret != "") ret += "\r\n";
                ret += string.Format("{1}: #{0}", cell.RowHandle, Properties.Resources.Row);
            }
            ret += "\r\n    " + view.GetRowCellDisplayText(cell.RowHandle, cell.Column);
            rowIndex = cell.RowHandle;
        }
    }
    return ret;
}

 

+ Recent posts