<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[farbige Zeile in einer Stringgrid]]></title><description><![CDATA[<p>Hallo,<br />
nutze folgender Code, um Zeilen im StringGrid farbig dazustellen.<br />
Wenn zB. eine Fehlermeldung kommt, stelle ich diese Zeilen rot da.<br />
Problem, beim scrollen werden danach alle Zeilen rot dargestellt.<br />
Frage: muß ich in einem Speicher die Farbwerte zwischenspeichern, oder lößt man dies anderst ?</p>
<pre><code class="language-cpp">//
    if (StringGridFarbIndex &gt; 0)
      {   //  StringGridFarbIndex &gt; 0
    //
    switch (StringGridFarbIndex)
      {   //  switch (StringGridFarbIndex)
        //
        case 1: case 2: case 3: case 4:
          {   //  case 1
            //    Standardfarben für selektierte Zelle(n)
            if (State.Contains(gdSelected))
              {
              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clHighlight;
              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clHighlightText;
              }
            // gerade Zeilen Dunkelgrau, aber nicht die feste(n) Zeile(n) oben
            else if (ARow % 2 &amp;&amp; !State.Contains(gdFixed))
              {
              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clGray;
              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clWhite;
              }
            // gerade Spalten Hellgrau, aber nicht ... links
            else if (ACol % 10 &amp;&amp; !State.Contains(gdFixed))
              {
              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clMedGray;    //clSilver;
              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clWhite;
              }
            // Zelle 2/2 Gelb
            else if (ACol == 2 &amp;&amp; ARow == 2)
              {
//              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clYellow;
//              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clBlack;
              }
            //
          //  
          break;
          }   //  case 1
        //
        //
        case 100:
          {   //  case 100
            //    Standardfarben für selektierte Zelle(n)
            if (State.Contains(gdSelected))
              {
              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clRed;    //clHighlight;
              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clHighlightText;
              }
            // gerade Zeilen Dunkelgrau, aber nicht die feste(n) Zeile(n) oben
            else if (ARow % 2 &amp;&amp; !State.Contains(gdFixed))
              {
              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clRed;    //clGray;
              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clWhite;
              }
            // gerade Spalten Hellgrau, aber nicht ... links
            else if (ACol % 10 &amp;&amp; !State.Contains(gdFixed))
              {
              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clRed;    //clMedGray;    //clSilver;
              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clWhite;
              }
            // Zelle 2/2 Gelb
            else if (ACol == 2 &amp;&amp; ARow == 2)
              {
//              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clYellow;
//              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clBlack;
              }
            //
          //  
          break;
          }   //  case 100
        //

      }   //  switch (StringGridFarbIndex)
    //

  // Farben festlegen:

      // Zelle endlich zeichnen
      StringGrid1-&gt;Canvas-&gt;FillRect(Rect);
      // noch ein Gimmick für die Textausrichtung
      int hAlign;   // text align, 0/1/2 - Left/Center/Right
      if (ACol % 2)
        {
        hAlign = 1;
        }
      else
        {
        hAlign = 2;
        }
      hAlign = 0;
      // und zum Schluss den Text in die Zelle malen
      DrawText(StringGrid1-&gt;Canvas-&gt;Handle, StringGrid1-&gt;Cells[ACol][ARow].c_str(),
      -1, &amp;Rect, DT_SINGLELINE | DT_VCENTER | hAlign);
      //
      }   //  StringGridFarbIndex &gt; 0
    //
    //
</code></pre>
<p>Gruß Siegfried</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/142846/farbige-zeile-in-einer-stringgrid</link><generator>RSS for Node</generator><lastBuildDate>Tue, 04 Aug 2026 08:23:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/142846.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 03 Apr 2006 13:10:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to farbige Zeile in einer Stringgrid on Mon, 03 Apr 2006 13:10:47 GMT]]></title><description><![CDATA[<p>Hallo,<br />
nutze folgender Code, um Zeilen im StringGrid farbig dazustellen.<br />
Wenn zB. eine Fehlermeldung kommt, stelle ich diese Zeilen rot da.<br />
Problem, beim scrollen werden danach alle Zeilen rot dargestellt.<br />
Frage: muß ich in einem Speicher die Farbwerte zwischenspeichern, oder lößt man dies anderst ?</p>
<pre><code class="language-cpp">//
    if (StringGridFarbIndex &gt; 0)
      {   //  StringGridFarbIndex &gt; 0
    //
    switch (StringGridFarbIndex)
      {   //  switch (StringGridFarbIndex)
        //
        case 1: case 2: case 3: case 4:
          {   //  case 1
            //    Standardfarben für selektierte Zelle(n)
            if (State.Contains(gdSelected))
              {
              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clHighlight;
              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clHighlightText;
              }
            // gerade Zeilen Dunkelgrau, aber nicht die feste(n) Zeile(n) oben
            else if (ARow % 2 &amp;&amp; !State.Contains(gdFixed))
              {
              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clGray;
              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clWhite;
              }
            // gerade Spalten Hellgrau, aber nicht ... links
            else if (ACol % 10 &amp;&amp; !State.Contains(gdFixed))
              {
              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clMedGray;    //clSilver;
              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clWhite;
              }
            // Zelle 2/2 Gelb
            else if (ACol == 2 &amp;&amp; ARow == 2)
              {
//              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clYellow;
//              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clBlack;
              }
            //
          //  
          break;
          }   //  case 1
        //
        //
        case 100:
          {   //  case 100
            //    Standardfarben für selektierte Zelle(n)
            if (State.Contains(gdSelected))
              {
              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clRed;    //clHighlight;
              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clHighlightText;
              }
            // gerade Zeilen Dunkelgrau, aber nicht die feste(n) Zeile(n) oben
            else if (ARow % 2 &amp;&amp; !State.Contains(gdFixed))
              {
              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clRed;    //clGray;
              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clWhite;
              }
            // gerade Spalten Hellgrau, aber nicht ... links
            else if (ACol % 10 &amp;&amp; !State.Contains(gdFixed))
              {
              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clRed;    //clMedGray;    //clSilver;
              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clWhite;
              }
            // Zelle 2/2 Gelb
            else if (ACol == 2 &amp;&amp; ARow == 2)
              {
//              StringGrid1-&gt;Canvas-&gt;Brush-&gt;Color = clYellow;
//              StringGrid1-&gt;Canvas-&gt;Font-&gt;Color = clBlack;
              }
            //
          //  
          break;
          }   //  case 100
        //

      }   //  switch (StringGridFarbIndex)
    //

  // Farben festlegen:

      // Zelle endlich zeichnen
      StringGrid1-&gt;Canvas-&gt;FillRect(Rect);
      // noch ein Gimmick für die Textausrichtung
      int hAlign;   // text align, 0/1/2 - Left/Center/Right
      if (ACol % 2)
        {
        hAlign = 1;
        }
      else
        {
        hAlign = 2;
        }
      hAlign = 0;
      // und zum Schluss den Text in die Zelle malen
      DrawText(StringGrid1-&gt;Canvas-&gt;Handle, StringGrid1-&gt;Cells[ACol][ARow].c_str(),
      -1, &amp;Rect, DT_SINGLELINE | DT_VCENTER | hAlign);
      //
      }   //  StringGridFarbIndex &gt; 0
    //
    //
</code></pre>
<p>Gruß Siegfried</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1029656</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1029656</guid><dc:creator><![CDATA[Beppo]]></dc:creator><pubDate>Mon, 03 Apr 2006 13:10:47 GMT</pubDate></item><item><title><![CDATA[Reply to farbige Zeile in einer Stringgrid on Mon, 03 Apr 2006 13:15:39 GMT]]></title><description><![CDATA[<p>Beppo schrieb:</p>
<blockquote>
<p>Frage: muß ich in einem Speicher die Farbwerte zwischenspeichern, ...</p>
</blockquote>
<p>Ja. Du könntest dafür die Eigenschaft <strong>Objects</strong> benutzen, die es für jede Zelle gibt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1029660</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1029660</guid><dc:creator><![CDATA[Burkhi]]></dc:creator><pubDate>Mon, 03 Apr 2006 13:15:39 GMT</pubDate></item><item><title><![CDATA[Reply to farbige Zeile in einer Stringgrid on Mon, 03 Apr 2006 13:19:16 GMT]]></title><description><![CDATA[<p>Hallo,<br />
wie muß ich dies machen ?<br />
Gruß Siegfried</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1029663</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1029663</guid><dc:creator><![CDATA[Beppo]]></dc:creator><pubDate>Mon, 03 Apr 2006 13:19:16 GMT</pubDate></item><item><title><![CDATA[Reply to farbige Zeile in einer Stringgrid on Mon, 03 Apr 2006 13:22:06 GMT]]></title><description><![CDATA[<p>schau in die BCB-Hilfe<br />
<em>TStringGrid::Objects</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1029666</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1029666</guid><dc:creator><![CDATA[BigNeal]]></dc:creator><pubDate>Mon, 03 Apr 2006 13:22:06 GMT</pubDate></item><item><title><![CDATA[Reply to farbige Zeile in einer Stringgrid on Mon, 03 Apr 2006 13:22:34 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>siehe BCB Hilfe zu <em>TStringGrid::Rows::Objects</em>.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1029669</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1029669</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Mon, 03 Apr 2006 13:22:34 GMT</pubDate></item><item><title><![CDATA[Reply to farbige Zeile in einer Stringgrid on Mon, 03 Apr 2006 15:02:24 GMT]]></title><description><![CDATA[<p>Hallo,<br />
komme mit der Hilfe nicht weiter. wer kann mir helfen ?<br />
Gruß Siegfried</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1029742</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1029742</guid><dc:creator><![CDATA[Beppo]]></dc:creator><pubDate>Mon, 03 Apr 2006 15:02:24 GMT</pubDate></item><item><title><![CDATA[Reply to farbige Zeile in einer Stringgrid on Mon, 03 Apr 2006 15:11:32 GMT]]></title><description><![CDATA[<p>Hallo</p>
<pre><code class="language-cpp">/// schreibt und liest einen Farbwert in den Object-Speicher der Zelle in Zeile 1, Spalte 2
TColor color = clRed;
StringGrid-&gt;Rows[1]-&gt;Objects[2] = reinterpret_cast&lt;TObject*&gt;(color);
...
color = reinterpret_cast&lt;TColor&gt;(StringGrid-&gt;Rows[1]-&gt;Objects[2]);
</code></pre>
<p>Das solltest du natürlich nur so machen, wenn du auch Objects nicht andersweitig benutzt.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1029749</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1029749</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Mon, 03 Apr 2006 15:11:32 GMT</pubDate></item><item><title><![CDATA[Reply to farbige Zeile in einer Stringgrid on Mon, 03 Apr 2006 19:32:36 GMT]]></title><description><![CDATA[<p>Hallo,<br />
alles erledig, vielen Dank für eure Hilfe<br />
Gruß Siegfried</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1029893</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1029893</guid><dc:creator><![CDATA[Beppo]]></dc:creator><pubDate>Mon, 03 Apr 2006 19:32:36 GMT</pubDate></item><item><title><![CDATA[Reply to farbige Zeile in einer Stringgrid on Mon, 03 Apr 2006 20:07:46 GMT]]></title><description><![CDATA[<p>Alternativ könntest du auch einfach den Text der zu zeichnenden Zelle auf entsprechende Schlüsselwörter hin auswerten, also z.B. bei &quot;Fehler: blabla&quot; rot zeichnen etc.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1029911</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1029911</guid><dc:creator><![CDATA[Jansen]]></dc:creator><pubDate>Mon, 03 Apr 2006 20:07:46 GMT</pubDate></item></channel></rss>