<?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[Mehrere CheckBoxen und ListBox Problem?]]></title><description><![CDATA[<p>Hallo,<br />
ich habe ein kleines Problem.<br />
Es geht darum das ich in mein Programm 11 CheckBox's habe und einen ListBox.<br />
Jetzt möchte ich das wenn zum Beispiel CheckBox1 geklickt ist ein Name in ListBox geschriben wird und wenn ich denn hacken wieder raus nehme möchte ich das es aus der ListBox entfernt wird.<br />
Jetzt meine Frage gibt es eine möglichkeit das ich das alles in eine kleine (abfrage)/methode mache.<br />
Z.B.: von checkbox1 bis checkbox11<br />
oder muss ich für jeden CheckBox einzeln Manuel den passenden code schreiben?</p>
<p>Dank im Voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/195257/mehrere-checkboxen-und-listbox-problem</link><generator>RSS for Node</generator><lastBuildDate>Tue, 18 Aug 2026 09:20:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/195257.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 16 Oct 2007 00:17:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Mehrere CheckBoxen und ListBox Problem? on Tue, 16 Oct 2007 00:17:25 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich habe ein kleines Problem.<br />
Es geht darum das ich in mein Programm 11 CheckBox's habe und einen ListBox.<br />
Jetzt möchte ich das wenn zum Beispiel CheckBox1 geklickt ist ein Name in ListBox geschriben wird und wenn ich denn hacken wieder raus nehme möchte ich das es aus der ListBox entfernt wird.<br />
Jetzt meine Frage gibt es eine möglichkeit das ich das alles in eine kleine (abfrage)/methode mache.<br />
Z.B.: von checkbox1 bis checkbox11<br />
oder muss ich für jeden CheckBox einzeln Manuel den passenden code schreiben?</p>
<p>Dank im Voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1386002</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1386002</guid><dc:creator><![CDATA[titanium]]></dc:creator><pubDate>Tue, 16 Oct 2007 00:17:25 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrere CheckBoxen und ListBox Problem? on Tue, 16 Oct 2007 07:17:41 GMT]]></title><description><![CDATA[<p>schau mal in der FAQ, z.B. <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39210.html" rel="nofollow">Sendernamen bei einer OnClick-Prozedur identifizieren</a> und <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39207.html" rel="nofollow">Zugriff, aber nicht durch Namen</a></p>
<p>du kannst allen CheckBoxen das gleiche Ereignis zuweisen und dann die einzelnen CheckBoxen über den Sendernamen oder noch besser über den Tag des Senders identifizieren, dazu mußt du natürlich erst jeder CheckBox einen Tag-Wert zuweisen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1386083</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1386083</guid><dc:creator><![CDATA[Linnea]]></dc:creator><pubDate>Tue, 16 Oct 2007 07:17:41 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrere CheckBoxen und ListBox Problem? on Tue, 16 Oct 2007 13:59:37 GMT]]></title><description><![CDATA[<p>Hi,<br />
danke für deine Antwort.<br />
Ist es möglicht das du mir Bitte ein Beispiel code schreibst.<br />
Verstanden habe ich das irgendwie, aber wie ich es realiseren null ahnung.<br />
Ein Beispiel wäre ganz nett.</p>
<p>Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1386435</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1386435</guid><dc:creator><![CDATA[titanium]]></dc:creator><pubDate>Tue, 16 Oct 2007 13:59:37 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrere CheckBoxen und ListBox Problem? on Wed, 17 Oct 2007 00:56:51 GMT]]></title><description><![CDATA[<p>Hallo titanium<br />
folgender Code arbeitet mit Senderabfrage.</p>
<pre><code class="language-cpp">void __fastcall THauptFenster::CheckBox1Click(TObject *Sender)
{

if(Sender==CheckBox1)
	{
          if ( CheckBox1-&gt;Checked)

             {ListBox1-&gt;Items-&gt;Add( &quot;CheckBox1&quot;);}
          else
            {if (ListBox1-&gt;Items-&gt;IndexOf(&quot;CheckBox1&quot;)!=-1)
                {ListBox1-&gt;Items-&gt;Delete(ListBox1-&gt;Items-&gt;IndexOf(&quot;CheckBox1&quot;));}
            };

        } ;

if(Sender==CheckBox2)
	{
          if ( CheckBox2-&gt;Checked)

             {ListBox1-&gt;Items-&gt;Add( &quot;CheckBox2&quot;);}
          else
            {if (ListBox1-&gt;Items-&gt;IndexOf(&quot;CheckBox2&quot;)!=-1)
                {ListBox1-&gt;Items-&gt;Delete(ListBox1-&gt;Items-&gt;IndexOf(&quot;CheckBox2&quot;));}
            };

        } ;

if(Sender==CheckBox3)
	{
          if ( CheckBox3-&gt;Checked)

             {ListBox1-&gt;Items-&gt;Add( &quot;CheckBox3&quot;);}
          else
            {if (ListBox1-&gt;Items-&gt;IndexOf(&quot;CheckBox3&quot;)!=-1)
                {ListBox1-&gt;Items-&gt;Delete(ListBox1-&gt;Items-&gt;IndexOf(&quot;CheckBox3&quot;));}
            };

        } ;

}
</code></pre>
<p>Der Code benötigt eine Listbox namens ListBox1 im Hauptfenster<br />
und drei Checkboxen namens CheckBox1 - 3.<br />
Im Objektinspektor/Ereignisse/OnClick sind bei allen Checkboxen<br />
CheckBox1Click angegeben.</p>
<p>MFG Schlumpi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1386783</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1386783</guid><dc:creator><![CDATA[Schlumpi]]></dc:creator><pubDate>Wed, 17 Oct 2007 00:56:51 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrere CheckBoxen und ListBox Problem? on Wed, 17 Oct 2007 01:41:06 GMT]]></title><description><![CDATA[<p>Hi,<br />
Danke dir es läuft.<br />
Schlumpi, das letzt was duu geschrieben hast war interressant.</p>
<blockquote>
<p>Der Code benötigt eine Listbox namens ListBox1 im Hauptfenster<br />
und drei Checkboxen namens CheckBox1 - 3.<br />
Im Objektinspektor/Ereignisse/OnClick sind bei allen Checkboxen<br />
CheckBox1Click angegeben.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1386785</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1386785</guid><dc:creator><![CDATA[titanium]]></dc:creator><pubDate>Wed, 17 Oct 2007 01:41:06 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrere CheckBoxen und ListBox Problem? on Wed, 17 Oct 2007 09:34:22 GMT]]></title><description><![CDATA[<p>Sorry, Schlumpi, aber dein Code ist ja grausam, denn dann hätte man auch gleich verschiedene Methoden je Checkbox nehmen können.</p>
<p>So macht man es richtig:</p>
<pre><code class="language-cpp">void __fastcall THauptFenster::CheckBoxClick(TObject *Sender)
{
  TCheckBox *pCheckBox = dynamic_cast&lt;TCheckBox*&gt;(Sender); // oder static_cast, falls kein RTTI eingeschaltet ist
  if(pCheckBox)
  {
    if ( pCheckBox-&gt;Checked)
    {
      ListBox1-&gt;Items-&gt;Add( pCheckBox-&gt;Name );
    }
    else
    {
      int nIdx = ListBox1-&gt;Items-&gt;IndexOf( pCheckBox-&gt;Name );
      if (nIdx !=-1)
         ListBox1-&gt;Items-&gt;Delete(nIdx);
    };
  };
}
</code></pre>
<p>Alternativ, wie Linnea schon geschrieben hat, kann man auch die Eigenschaft 'Tag' benutzen und z.B. aus einem Array oder std::vector den angezeigten Namen lesen:</p>
<pre><code class="language-cpp">AnsiString sName = vecNames[pCheckBox-&gt;Tag].c_str();
</code></pre>
<p>Aber du solltest trotzdem mal die FAQ Beiträge lesen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1386957</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1386957</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Wed, 17 Oct 2007 09:34:22 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrere CheckBoxen und ListBox Problem? on Wed, 17 Oct 2007 14:45:38 GMT]]></title><description><![CDATA[<p>Hallo titanium<br />
hier noch ein konkretes Beispiel.</p>
<pre><code class="language-cpp">TForm1 *Form1;
TStringList * StrChk;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
 StrChk = new TStringList;
 StrChk-&gt;AddObject(&quot;Januar&quot;,CheckBox1);
 StrChk-&gt;AddObject(&quot;Februar&quot;,CheckBox2);
 StrChk-&gt;AddObject(&quot;März&quot;,CheckBox3);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::CheckBox1Click(TObject *Sender)
{
 TCheckBox * CheckBoxDummy = dynamic_cast&lt;TCheckBox*&gt;(Sender);

 int Zeile = -1;
 Zeile = StrChk-&gt;IndexOfObject(CheckBoxDummy);
 if (Zeile == -1){return ; };

 if ( CheckBoxDummy-&gt;Checked)
     ListBox1-&gt;Items-&gt;Add(StrChk-&gt;Strings[Zeile]);

 else{

      if ( ListBox1-&gt;Items-&gt;IndexOf(StrChk-&gt;Strings[Zeile]) != -1)
          { ListBox1-&gt;Items-&gt;Delete(ListBox1-&gt;Items-&gt;
            IndexOf(StrChk-&gt;Strings[Zeile]) );
          };

    };
}
</code></pre>
<p>MFG Schlumpi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1387270</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1387270</guid><dc:creator><![CDATA[Schlumpi]]></dc:creator><pubDate>Wed, 17 Oct 2007 14:45:38 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrere CheckBoxen und ListBox Problem? on Wed, 17 Oct 2007 21:19:13 GMT]]></title><description><![CDATA[<p>WOW.<br />
Danke läute für die Tipps und Codes. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1387498</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1387498</guid><dc:creator><![CDATA[titanium]]></dc:creator><pubDate>Wed, 17 Oct 2007 21:19:13 GMT</pubDate></item></channel></rss>