Autor Beitrag
dreamtheater
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 46



BeitragVerfasst: Fr 21.03.03 19:49 
Hallo!
Wie könnte ich am Einfachsten in einem StringGrid den Text *bestimmter* Zellen in bold font schreiben?
Danke,
dreamtheater
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 21.03.03 20:12 
Hm, spontan würde ich sagen, dass Du die Schrift im OnDrawCell-Ereignis des Grids selbst erstellst.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
dreamtheater Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 46



BeitragVerfasst: Fr 21.03.03 20:16 
Ja, das habe ich mir auch schon überlegt... hast Du einen kurzen Tip, wie in etwa das aussehen könnte?
THX
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 21.03.03 20:17 
Also, wenn Du beispielsweise die Schrift in den Feldern, die auf der Hauptdiagonalen liegen, fett drucken willst, mach es so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  with StringGrid1.Canvas do
  begin
    if ACol = ARow then Font.Style:=Font.Style+[fsBold];
    TextRect(Rect,Rect.Left,Rect.top,StringGrid1.Cells[ACol,ARow]);
    Font.Style:=Font.Style-[fsBold];
  end;
end;

Habe das ohne Delphi geschrieben, können also noch Fehler drin sein.

MfG,
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
dreamtheater Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 46



BeitragVerfasst: Sa 22.03.03 20:22 
Danke, das haut hin!
blackbirdXXX

ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1077
Erhaltene Danke: 1

Ubuntu Dapper

BeitragVerfasst: So 01.06.03 12:47 
Titel: font und kuriv auf label
Wenn ich mit
ausblenden Delphi-Quelltext
1:
2:
  label1.Font.Style := font.style+[fsbold];
  label1.Font.Style := font.style+[fsitalic];

den Text Kuriv und Fett machen will wird er nur Fett.
Aber ich will nicht
label1.Font.Style := font.style+[fsitalic, fsbold]; oder so.

_________________
Klein, schwarz und ärgert Techniker? Jumper!
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 01.06.03 12:56 
Könnte es sein, dass Du mit "label1.font.style" (linke Seite) und "font.style" nicht die gleichen Styles ansprichst? Wenn ja, dann solltest Du es so machen:

ausblenden Delphi-Quelltext
1:
2:
label1.Font.Style := font.style+[fsbold];
label1.Font.Style := label1.font.style+[fsitalic];


MfG,
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
blackbirdXXX

ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1077
Erhaltene Danke: 1

Ubuntu Dapper

BeitragVerfasst: So 01.06.03 13:02 
Danke. Das funktioniert.

_________________
Klein, schwarz und ärgert Techniker? Jumper!