IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Delphi Discussion :

[StringGrid] comment selectionner une cellule avec bouton droite


Sujet :

Delphi

  1. #1
    Membre régulier Avatar de Bourak
    Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2005
    Messages
    231
    Détails du profil
    Informations personnelles :
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Octobre 2005
    Messages : 231
    Points : 84
    Points
    84
    Par défaut [StringGrid] comment selectionner une cellule avec bouton droite
    salut!

    J'ai une stringgrid remplisser par des textes. Lorsque je veut selectionner une cellule, la selection ne se fait qu'avec le boutton gauche de la souris.
    je voudrais que cette selection se fait avec la boutton droite, car j'ai ajouter un context popup pour différent utilisation telque la suppression du texte de cette cellule;

    Merci d'avance

  2. #2
    Membre émérite Avatar de edam
    Homme Profil pro
    Développeur Delphi/c++/Omnis
    Inscrit en
    Décembre 2003
    Messages
    1 894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Delphi/c++/Omnis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2003
    Messages : 1 894
    Points : 2 770
    Points
    2 770
    Par défaut
    un example qui contient quelque erreur dans la selection et dans la relache de la sourie si il est relacher en dehors de grid
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    unit Unit1;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, Buttons, ExtCtrls, Grids;
     
    type
       TIntegerArray = array of Integer;
      TForm1 = class(TForm)
        StringGrid1: TStringGrid;
        procedure StringGrid1MouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure StringGrid1MouseUp(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
      private
        { Déclarations privées }
        Procedure Mon(Sender: TObject; Shift: TShiftState; X, Y: Integer);
      public
        { Déclarations publiques }
      end;
     
    var
      Form1: TForm1;
     
    implementation
     
    {$R *.DFM}
    var
        s:string;
        pos:TGridRect;
    procedure TForm1.Mon;
    begin
         StringGrid1.MouseToCell(x,y,pos.Right,pos.Bottom);
         if (pos.Right>0) and (pos.Bottom>0) then StringGrid1.Selection:=pos;
    end;
    procedure TForm1.StringGrid1MouseDown(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    begin
         if ssRight	in shift then
           begin
               StringGrid1.MouseToCell(x,y,pos.Left,pos.Top);
               if (pos.Left>0) and (pos.Top>0) then
                 begin
                   pos.Right:=pos.Left;
                   pos.Bottom:=pos.Top;
                   StringGrid1.Selection:=pos;
                   StringGrid1.OnMouseMove:=Mon;
                 end;
           end;
    end;
    procedure TForm1.StringGrid1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
         if Assigned(StringGrid1.OnMouseMove) then
         StringGrid1.OnMouseMove:=nil;
    end;
     
    end.
    PAS DE DESTIN, C'EST CE QUE NOUS FAISONS

  3. #3
    Membre régulier Avatar de Bourak
    Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2005
    Messages
    231
    Détails du profil
    Informations personnelles :
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Octobre 2005
    Messages : 231
    Points : 84
    Points
    84
    Par défaut
    Merci edam

    je vais tester ce code

    A bientôt Inchallah!

    merci

  4. #4
    Membre régulier Avatar de Bourak
    Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2005
    Messages
    231
    Détails du profil
    Informations personnelles :
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Octobre 2005
    Messages : 231
    Points : 84
    Points
    84
    Par défaut
    merci
    Elle marche bien !

    Pas d'erreur dans ce prgramme!
    merci !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2007] Utilisation d'une cellule avec un "-" à droite du nombre
    Par Blacktizen dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 25/02/2015, 16h57
  2. [XL-2003] Changer la couleur de fond d'une cellule avec clic droit
    Par cyr.odi dans le forum Macros et VBA Excel
    Réponses: 21
    Dernier message: 10/09/2012, 11h33
  3. [OpenOffice][Tableur] Comment selectionner une cellule
    Par Patbart dans le forum OpenOffice & LibreOffice
    Réponses: 1
    Dernier message: 16/10/2009, 13h56
  4. [XSLT] - Comment selectionner une balise avec un nom variable ?
    Par bchabot dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 25/04/2006, 09h59
  5. [C#]Comment forcer la sélection d'un noeud avec bouton droit
    Par irnbru dans le forum Windows Forms
    Réponses: 3
    Dernier message: 16/11/2005, 19h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo