Einzelnen Beitrag anzeigen

lucy

Registriert seit: 25. Okt 2017
63 Beiträge
 
Delphi XE7 Starter
 
#1

ComboBox im StringGrid für bestimmte Zeilen deaktivieren

  Alt 27. Okt 2017, 18:14
Hallo,
wenn ein bestimmter Wert in einer Spalte steht zB. "Hallo" soll in dieser Zeile die ComboBox gesperrt werden.

Hier wird die ComboBox weiterhin Angezeigt?

Delphi-Quellcode:
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
  var CanSelect: Boolean);
var
  R: TRect;
  org: TPoint;
begin
   if (stringgrid1.Cells[4,StringGrid1.Row]='hallo') then
    begin
    // CanSelect := FALSE;
    end else
     begin
  if (ACol = 6) and (ARow >= StringGrid1.FixedRows) then begin
    StringGrid1.Perform(WM_CANCELMODE, 0, 0);
    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);
      ItemIndex := Items.IndexOf(StringGrid1.Cells[ACol, ARow]);
      Show;
      BringToFront;
      SetFocus;
      DroppedDown := true;
    end;
    end;
  end;
  Mit Zitat antworten Zitat