Hallo, ich versuche verzweifelt eine Gauge in einem StringGrid zu setzen, in einem ListView habe ich es auch geschaft und dachte ich könnte es halt auf ein StringGrid umsetzen.
Listiew Code:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22:
| procedure TForm1.Button1Click(Sender: TObject); var r: TRect; pb: TProgressBar; mgauge : TGauge; begin Listview1.Columns.Add.Width := 100; Listview1.Columns.Add.Width := 200; Listview1.ViewStyle := vsReport; Listview1.Items.Add.Caption := 'Text';
r := Listview1.Items[0].DisplayRect(drBounds); r.Left := r.Left + Listview1.columns[0].Width; r.Right := r.Left + Listview1.columns[1].Width;
mGauge := TGauge.Create(self); mGauge.Parent := listview1; mgauge.BoundsRect := r; mGauge.Progress := 0; Listview1.Items[0].Data := mGauge;
end; |
Und nun der Versuch mit nem StringGrid:
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:
| procedure TForm6.Button1Click(Sender: TObject); var mGauge: TGauge; begin mGauge := TGauge.Create(Stringgrid1); mGauge.Parent := stringgrid1; mGauge.Progress := 0; stringgrid1.Objects[2,2] := mGauge; end;
procedure TForm6.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var tmpGauge : TGauge; begin if (Acol = 2) AND (Arow = 2) then begin if stringgrid1.Objects[2,2] <> nil then begin tmpGauge := (stringgrid1.Objects[2,2] as TGauge); with tmpGauge do begin Left := Rect.Left; Top := Rect.Top; Width := Rect.Right - Rect.Left; Height := Rect.Bottom - Rect.Top; end; end; end; end; |
Das Problem beim StringGrid ist halt, dass die Gauge nicht in der Zelle gesetzt wird, sondern am oberen linken Rand des Grids und die Gauge verdeckt mehrere Zellen.
Hat einer von Euch eine Lösung?
Gruss Jolomino