Autor Beitrag
saxe66
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 104



BeitragVerfasst: Di 30.10.12 11:25 
Hallo Delphianer, vielleicht hat jemand eine Lösung für folgendes Problem:
Ich möchte in einem DBGrid Lieferscheinpositionen anzeigen, die Tabelle hat auch ein Memofeld, welches im Grid nur als (Memo)- Eintrag erscheint.
Dieses Memo soll nun idealerweise an die Hint-Komponente übergeben werden, sobald man mit der Maus über die entsprechende Zeile fährt.
Hat jemand eine Idee, wie man dies realisieren kann bzw. ob es dafür fertige Lösungen gibt ?

Danke im Voraus
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Di 30.10.12 23:02 
ich würde dafür irgendwo ein DBMemo anzeigen, wo das Problem liegt siehst Du wenn Du folgendes ausprobierst ...

ausblenden volle Höhe Delphi-Quelltext
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:
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, DB, ADODB;

type
  TDBGrid=Class(DBGrids.TDBgrid)
    Property Row;
    Property TopRow;
  End;
  TForm3 = class(TForm)
    ADOConnection1: TADOConnection;
    ADODataSet1: TADODataSet;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    procedure DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
  private
    { Private-Deklarationen }
    FGCoord:TGridCoord;
  public
    { Public-Deklarationen }
  end;

var
  Form3: TForm3;

implementation
uses Math;
{$R *.dfm}

procedure TForm3.DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
  var
   COOrd:TGridCoord;
begin
   COOrd :=DBGrid1.MouseCoord(X,y) ;
   if ((COOrd.X>-1and (COOrd.Y>0)) and ((COOrd.X<>FGCoord.X) or (COOrd.Y<>FGCoord.Y)) then
      begin
          // hier finde ich nichts brauchbares um Satz / Anzeige und Maus zu synchronisieren
          AdoDataset1.RecNo :=  COOrd.Y+ DBGrid1.Toprow;

          DBgrid1.Hint := '';
          if DBgrid1.Columns[COOrd.X-1].Field.FieldName='Field5' then
            begin
               DBgrid1.Hint := DBgrid1.Columns[COOrd.X].Field.asString;
               Application.ActivateHint(DBGrid1.ClientToScreen( Point(X,y)));
            end;

      end
      else
        begin
        Application.CancelHint;
        end;
end;

end.

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS