AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein runtime popupmenu on specific TDBGrid cell
Thema durchsuchen
Ansicht
Themen-Optionen

runtime popupmenu on specific TDBGrid cell

Ein Thema von question · begonnen am 24. Sep 2013 · letzter Beitrag vom 25. Sep 2013
Antwort Antwort
Volker Z.

Registriert seit: 3. Dez 2012
Ort: Augsburg, Bayern, Süddeutschland
419 Beiträge
 
Delphi XE4 Ultimate
 
#1

AW: runtime popupmenu on specific TDBGrid cell

  Alt 24. Sep 2013, 22:35
Hallo,

if I' ve got it right, you want to display a popup menu next to the selected cell of your grid only if some conditions are fulfilled.
Why do you wanna create the popup menu at runtime? I can' t see any need. I would suggest:
  • put a TPopup component on your form
  • create all the menu items you need
  • set the AutoPopup property of your popup menu to false
  • set the PopupMenu property of your TDBGrid component to the popup menu
  • provide a OnMouseUp event handler to your TDBGrid component with code like the following
Delphi-Quellcode:
procedure TForm1.DBGrid1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  c : TGridCoord;
  p : TPoint;
begin
  if Button = mbRight then
    begin
      c := DBGrid1.MouseCoord (X, Y);
      if (c.X = 0) or (c.Y = 0) then
        // no popup on a fixed col or row
        Exit;

      if YourConditionsAreFulfilled then
        begin
          // do some adjustment to the popup menu
          p := DBGrid1.ClientToScreen (Point (X, Y));
          PopupMenu1.Popup (p.X, p.Y)
        end
    end
end;
That should do.


Best regards
Volker Zeller
  Mit Zitat antworten Zitat
question

Registriert seit: 17. Apr 2013
97 Beiträge
 
#2

AW: runtime popupmenu on specific TDBGrid cell

  Alt 24. Sep 2013, 22:57
Hi, thanks for your reply, i have tried it ,it works but i have several grid in one form and several Form contains several grids , if i use this approach then i need to add many popup components(dbgrids,dbgrid2...and so on) ,therefore i am looking for a option ,so that i can create in runtime,is that possible
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:09 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz