Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 11.03.05 15:37 
Hi, Delpher,

(wie) kann ich die Inhalte der nicht selektierten Zellen in einem Stringgrid löschen?

2 For-Schleifen ??

Danke für eure Hilfe,
Detlef Annies
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Fr 11.03.05 15:41 
user profile iconD. Annies hat folgendes geschrieben:
2 For-Schleifen ??


Ja. Wobei du in der OH schauen müsstest wie du die aktuell selektierte Zelle herausfindest.

AXMD
Shark
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 87

98, XP
D3, D5, D7
BeitragVerfasst: Fr 11.03.05 15:42 
mit der OnDrawCell-Methode

if (gdSelected in AState) then...

edit: unsichtbar machen dachte ich
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 11.03.05 21:00 
Hi,

danke für eure Ideen, habe es lösen können durch eine function, die bei selektion einer Zelle boolsch true wird.

Danach Prüfung mit 2 For-Schleifen zellenweise: if not selektiert then ''.

Viele Grüße,
Detlef Annies
EUOCheffe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124



BeitragVerfasst: Fr 11.03.05 21:08 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
  for x:=0 to Grid.ColCount-1 do
    for y:=0 to Grid.RowCount-1 do
      with Grid.Selection do
        if (x<Left)or(x>Right)or(y<Top)or(y>Bottom) then
          Grid.Cells[x,y]:='';


Geht auch mit einer einzigen FOR Schleife:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
  for c:=0 to (Grid.ColCount*Grid.RowCount)-1 do
    with Grid,Grid.Selection do
      if (c mod ColCount<Left)or(c mod ColCount>Right)or
        (c div ColCount<Top)or(c div ColCount>Bottom) then
          Grid.Cells[c mod ColCount,c div ColCount]:='';


Vielleicht etwas umständlich, aber hey, es geht ja um's Prinzip :)
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 12.03.05 19:39 
Hi, EUOCheffe,

vielen Dank für deine privmsg!

genau auf diese Lösung habe ich gewartet, allerdings doch über das logische Gegenteil, da ich die fixierten Spalten ausklammern muss. Echt 8) deine Lösung, danke!

Gruß,
Detlef Annies