folgendes Problem:
habe ein StringGrid, in dessen Zelle ich eine Combobox aufrufe. Dies funktioniert soweit auch.
Leider wird nach der Wahl eines Inhalts der ComboBox eine erneute Zelle im Stringgrid aufgerufen. Wie kann ich dem Program sagen, dass nach dem ComboBoxaufruf keine Zelle im StringGrid erneut geklickt wurde???
Habe den ganzen Tag das Forum durchsucht und bin leider nicht fündig geworden. Denke, es muss nur eine Variable zurückgesetzt werden wie >ComboBox1.hide< oder so?!
Bsp:
Code: Alles auswählen
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Grids,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
ComboBox1: TComboBox;
StringGrid1: TStringGrid;
procedure ComboBox1Select(Sender: TObject);
procedure StringGrid1SelectCell(Sender: TObject; aCol, aRow: Integer;
var CanSelect: Boolean);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.StringGrid1SelectCell(Sender: TObject; aCol, aRow: Integer;
var CanSelect: Boolean);
var
R:TRect;
org:TPoint;
b:byte;
begin
if (ACol>1) and (ARow>1) then begin
ComboBox1.Parent := StringGrid1;
R:=StringGrid1.CellRect(ACol, ARow);
org:=self.ScreenToClient(self.ClientToScreen(R.TopLeft));
with ComboBox1 do begin
SetBounds(org.X, org.Y, R.Right-R.Left, StringGrid1.Height);
Clear;
for b:=0 to 5 do items.Add('Wahl'+inttostr(b));
ItemIndex:=Items.IndexOf(StringGrid1.Cells[ACol, ARow]);
Show;
// BringToFront;
// SetFocus;
DroppedDown := true;
end;
end;
end;
procedure TForm1.ComboBox1Select(Sender: TObject);
begin
StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row]:=ComboBox1.Items[ComboBox1.Itemindex];
ComboBox1.Hide; //funktioniert nicht
ComboBox1.Visible:=false; //funktioniert nicht
StringGrid1.BringToFront; //funktioniert nicht
StringGrid1.Refresh; //funktioniert nicht
StringGrid1.Repaint; //funktioniert nicht
end;
end.