AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

StringGrid Zeile einfärben

Ein Thema von strom · begonnen am 28. Dez 2014 · letzter Beitrag vom 13. Jan 2015
 
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#27

AW: StringGrid Zeile einfärben

  Alt 13. Jan 2015, 13:42
Also es es wäre zuckersüß, wenn man Delphi-Sourcecode auch in die dafür vorgesehenen Delphi-Tags packen könnte:
Code:
[DELPHI]
procedure foo;
begin
  // do something
end;
[/DELPHI]
Dann sieht das so aus:
Delphi-Quellcode:
procedure foo;
begin
  // do something
end;
Toll, gell?

So jetzt mal zum Thema (ähm, welchem eigentlich):
Delphi-Quellcode:
unit Form.Main;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.StdCtrls;

type
  TForm1 = class( TForm )
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    StringGrid1: TStringGrid;
    procedure StringGrid1SelectCell( Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean );
  private
    function CanSelectCell( ACol, ARow: Integer ): Boolean;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function TForm1.CanSelectCell( ACol, ARow: Integer ): Boolean;
begin
  Result := not(
    {} ( ( ComboBox1.ItemIndex = 1 ) and ( ACol >= 0 ) and ( ACol <= 2 ) ) or
    {}( ( ComboBox2.ItemIndex = 1 ) and ( ARow >= 1 ) and ( ARow <= 3 ) ) );
end;

procedure TForm1.StringGrid1SelectCell( Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean );
begin
  CanSelect := CanSelectCell( ACol, ARow );
end;

end.
Die Werte muss man eventuell noch anpassen, denn die Zeilen und Spalten sind 0 basiert, heisst also die erste Spalte ist die Spalte 0, analog mit der Zeile.
Und bei der ComboBox sieht es genauso aus, der erste Eintrag hat den ItemIndex 0.
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
 


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:19 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