<?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[dynamisches StringGrid mit eigenem OnDrawCell-Ereignis]]></title><description><![CDATA[<p>Hallo,<br />
ich möchte ein StringGrid dynamisch erstellen und darin OnDrawCell selbst erstellen.<br />
Bei der Zuweisung meiner eigenen Funktion myStrGrid-&gt;OnDrawCell= myStrGridDrawCell; sperrt der Compiler mit Fehlermeldungen.<br />
Wie komme ich nun weiter? Kann jemand sehen, was ich falsch mache?</p>
<p>Anbei mein Lösungsversuch:</p>
<pre><code class="language-cpp">//Unit1.h
class TForm1 : public TForm {
__published:	
  void __fastcall FormDestroy(TObject *Sender);
private:	
  TStringGrid* myStrGrid;
  void __fastcall myStrGridDrawCell(TObject *Sender, int ACol, int ARow,TRect &amp;Rect, TGridDrawState State);
...
};

//Unit1.cpp
__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner){
....
  myStrGrid = new TStringGrid(TabSheet1);
  myStrGrid-&gt;Parent = TabSheet1; 
  myStrGrid-&gt;OnDrawCell = myStrGridDrawCell; //eigenes OnDrawCell-Ereignis zuweisen, hier FEHLER
}

void __fastcall TForm1::myStrGridDrawCell(TObject *Sender, int ACol, int ARow,
                                             TRect &amp;Rect, TGridDrawState State) {....}

void __fastcall TForm1::FormDestroy(TObject *Sender){  // Speicher aufräumen:
  if (myStrGrid != NULL) {
    delete myStrGrid;
    myStrGrid = NULL;
  }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/198751/dynamisches-stringgrid-mit-eigenem-ondrawcell-ereignis</link><generator>RSS for Node</generator><lastBuildDate>Tue, 18 Aug 2026 18:47:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/198751.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 Nov 2007 06:56:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to dynamisches StringGrid mit eigenem OnDrawCell-Ereignis on Sun, 25 Nov 2007 06:56:14 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich möchte ein StringGrid dynamisch erstellen und darin OnDrawCell selbst erstellen.<br />
Bei der Zuweisung meiner eigenen Funktion myStrGrid-&gt;OnDrawCell= myStrGridDrawCell; sperrt der Compiler mit Fehlermeldungen.<br />
Wie komme ich nun weiter? Kann jemand sehen, was ich falsch mache?</p>
<p>Anbei mein Lösungsversuch:</p>
<pre><code class="language-cpp">//Unit1.h
class TForm1 : public TForm {
__published:	
  void __fastcall FormDestroy(TObject *Sender);
private:	
  TStringGrid* myStrGrid;
  void __fastcall myStrGridDrawCell(TObject *Sender, int ACol, int ARow,TRect &amp;Rect, TGridDrawState State);
...
};

//Unit1.cpp
__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner){
....
  myStrGrid = new TStringGrid(TabSheet1);
  myStrGrid-&gt;Parent = TabSheet1; 
  myStrGrid-&gt;OnDrawCell = myStrGridDrawCell; //eigenes OnDrawCell-Ereignis zuweisen, hier FEHLER
}

void __fastcall TForm1::myStrGridDrawCell(TObject *Sender, int ACol, int ARow,
                                             TRect &amp;Rect, TGridDrawState State) {....}

void __fastcall TForm1::FormDestroy(TObject *Sender){  // Speicher aufräumen:
  if (myStrGrid != NULL) {
    delete myStrGrid;
    myStrGrid = NULL;
  }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1409670</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409670</guid><dc:creator><![CDATA[thunderbol4]]></dc:creator><pubDate>Sun, 25 Nov 2007 06:56:14 GMT</pubDate></item><item><title><![CDATA[Reply to dynamisches StringGrid mit eigenem OnDrawCell-Ereignis on Sun, 25 Nov 2007 08:25:27 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>es muss <strong>const</strong> TRect &amp;Rect lauten:</p>
<pre><code class="language-cpp">void __fastcall StringGrid1DrawCell(TObject *Sender, int ACol, int ARow,
		  const TRect &amp;Rect, TGridDrawState State);
</code></pre>
<p>Gruß Peter</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1409677</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409677</guid><dc:creator><![CDATA[Peter24]]></dc:creator><pubDate>Sun, 25 Nov 2007 08:25:27 GMT</pubDate></item><item><title><![CDATA[Reply to dynamisches StringGrid mit eigenem OnDrawCell-Ereignis on Sun, 25 Nov 2007 13:01:11 GMT]]></title><description><![CDATA[<p>Danke <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/16191">@Peter24</a><br />
klappt jetzt, wie gewünscht.</p>
<p>woher weißt Du das mit <strong>const TRect</strong>?</p>
<p>Mein BCB6 gibt im OI beim Doppelklick unter OnDrawCell</p>
<pre><code class="language-cpp">void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
      int ARow, TRect &amp;Rect, TGridDrawState State)
{}
</code></pre>
<p>vor.</p>
<p>Ist das ein Bug im BCB6? Oder muß ich das auch bei anderen Events beachten, wenn die dynamisch erstellt werden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1409769</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409769</guid><dc:creator><![CDATA[thunderbol4]]></dc:creator><pubDate>Sun, 25 Nov 2007 13:01:11 GMT</pubDate></item><item><title><![CDATA[Reply to dynamisches StringGrid mit eigenem OnDrawCell-Ereignis on Sun, 25 Nov 2007 14:36:02 GMT]]></title><description><![CDATA[<p>Beim BCB5 ging es noch mit &quot;TRect &amp;Rect&quot;, nur in der Hilfe steht etwas anderes: &quot;TRect Rect&quot;.</p>
<p>Demnach haben sie beim BCB6 den Funktionsaufruf geändert, ohne die Anpassung im Objektinspektor vorzunehmen (daher kann man es als Bug bezeichnen).<br />
Bei anderen Ereignissen könnte so etwas auch sein, und wenn dann ein Compile-Fehler kommt, kann man ja die konkreten Parameter in den Header-Dateien nachschauen. Für die meisten Ereignisse dürften aber die Parameter korrekt sein.<br />
Aber dies ist unabhängig davon, ob die Komponente statisch oder dynamisch eingebunden wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1409843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409843</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Sun, 25 Nov 2007 14:36:02 GMT</pubDate></item><item><title><![CDATA[Reply to dynamisches StringGrid mit eigenem OnDrawCell-Ereignis on Sun, 25 Nov 2007 16:42:52 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/9348">@Th</a>, Danke für die Erklärung und den Tipp mit den Header-Dateien.</p>
<p>In der Regel wird es aber leider so sein, dass man verzweifelt nach einem Fehler im eigenen Programmcode sucht (wenn man sich noch nicht so sicher mit C++ ist).<br />
Aber gut, dass es dieses Board gibt, das einem dann weiterhelfen kann. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1409909</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409909</guid><dc:creator><![CDATA[thunderbol4]]></dc:creator><pubDate>Sun, 25 Nov 2007 16:42:52 GMT</pubDate></item></channel></rss>