Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   C++ Builder (https://www.clubdelphi.com/foros/forumdisplay.php?f=13)
-   -   Seleccionar fila con clic derecho en StringGrid (https://www.clubdelphi.com/foros/showthread.php?t=81168)

DSK25 18-10-2012 01:48:27

Seleccionar fila con clic derecho en StringGrid
 
Como puedo hacer que al hacer clic derecho con el mouse se seleccione la fila del StringGrid sobre la cual esta posicionada el cursor?

Gracias :)

ecfisa 18-10-2012 06:23:26

Hola DSK25.

Código:

void __fastcall TForm1::StringGrid1MouseDown(TObject *Sender,
  TMouseButton Button, TShiftState Shift, int X, int Y) {

  TStringGrid *Grid = static_cast<TStringGrid*>(Sender);
  if (Button == mbRight) {
    Grid->Row ? Grid->Row-- : Grid->Row++;
    Grid->Options = Grid->Options << goRowSelect;
    Grid->Row = ((TGridCoord)Grid->MouseCoord(X,Y)).Y;
  }
  else 
    Grid->Options = Grid->Options >> goRowSelect;
}

Con el botón derecho del mouse se activa la selección de fila y con el izquierdo se desactiva.

Saludos. :)

DSK25 19-10-2012 01:28:05

Gracias ecfisa, me sirvio perfectamente.


La franja horaria es GMT +2. Ahora son las 18:17:58.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi