Ver Mensaje Individual
  #2  
Antiguo 25-07-2012
Avatar de Al González
[Al González] Al González is offline
In .pas since 1991
 
Registrado: may 2003
Posts: 5.604
Reputación: 30
Al González Es un diamante en brutoAl González Es un diamante en brutoAl González Es un diamante en brutoAl González Es un diamante en bruto
Hola.

Creo que podrías valerte del evento OnEditing de la vista cx. Si asignas False al parámetro Boolean AAllow, lograrás evitar que el usuario modifique el valor de la celda que está intentando editar, y por lo mismo te sirve para toda una fila.

Seguramente hay otros caminos, pero este es el que a bote pronto se me ocurre.

Agrego: Ahora que leo tu pregunta nuevamente, noto que escribiste seleccionar y no editar. En ese caso OnCanSelectRecord es un evento más apropiado, según se describe en la propia ayuda:

Cita:
TcxCustomGridTableView.OnCanSelectRecord

Occurs before selecting a grid record.

Código Delphi [-]
type
  TcxGridCanSelectRecordEvent = procedure(Sender: TcxCustomGridTableView;
    ARecord: TcxCustomGridRecord; var AAllow: Boolean) of object;

property OnCanSelectRecord: TcxGridCanSelectRecordEvent;

Description

The OnCanSelectRecord event is fired only when the view’s OptionsSelection.MultiSelect property is set to True. Use this event to control record selection. The Sender parameter identifies the affected view and the ARecord parameter specifies the record to be selected. To enable record selection, set the AAllow parameter to True. This adds the current record to the collection of selected records.

Indexed access to selected records in default loading mode (when the GridMode property is set to False) is provided by the view’s Controller.SelectedRecords property. When GridMode is applied, see the view’s DataController.GetSelectedBookmark function to obtain selected records.

If the OnCanSelectRecord event handler sets AAllow to False, records will not be selected. However, OnCanSelectRecord does not allow you to prevent record focusing.

The following example disables selection of a record if its tvItemsSTATUS field denotes the ‘Fixed’ string. The value displayed by the item is determined by the indexed DisplayTexts property.

Código Delphi [-]
procedure TForm1.tvItemsCanSelectRecord(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  var AAllow: Boolean);
begin
  if ARecord.DisplayTexts[tvItemsSTATUS.Index] = 'Fixed' then

    AAllow := False;
end;

Última edición por Al González fecha: 25-07-2012 a las 00:19:16.
Responder Con Cita