<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Luigi Melisi &#187; GetItemChecked</title>
	<atom:link href="http://www.luigimelisi.com/tag/getitemchecked/feed" rel="self" type="application/rss+xml" />
	<link>http://www.luigimelisi.com</link>
	<description>Development Blog : C# Code Samples,.NET Tips and Tricks</description>
	<lastBuildDate>Thu, 03 Mar 2011 09:01:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>[C#] Determinare elementi spuntati in un controllo CheckedListBox</title>
		<link>http://www.luigimelisi.com/programmazione/net_framework/visual-c/c-determinare-elementi-spuntati-in-un-controllo-checkedlistbox.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=c-determinare-elementi-spuntati-in-un-controllo-checkedlistbox</link>
		<comments>http://www.luigimelisi.com/programmazione/net_framework/visual-c/c-determinare-elementi-spuntati-in-un-controllo-checkedlistbox.html#comments</comments>
		<pubDate>Sun, 15 Nov 2009 10:36:58 +0000</pubDate>
		<dc:creator>Luigi Melisi</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Visual C#]]></category>
		<category><![CDATA[.Net FrameWork]]></category>
		<category><![CDATA[CheckedItems]]></category>
		<category><![CDATA[checkedListBox]]></category>
		<category><![CDATA[GetItemChecked]]></category>

		<guid isPermaLink="false">http://www.luigimelisi.com/?p=334</guid>
		<description><![CDATA[Per la presentazione di dati in un controllo CheckedListBox di Windows Form è possibile scorrere l&#8217;insieme memorizzato nella proprietà CheckedItems o esaminare l&#8217;elenco utilizzando il metodo GetItemChecked per rilevare gli elementi selezionati. Il metodo GetItemChecked accetta il numero di indice  [...]]]></description>
			<content:encoded><![CDATA[<p>Per la presentazione di dati in un controllo <span>CheckedListBox</span> di Windows Form è possibile scorrere l&#8217;insieme memorizzato nella proprietà <span><strong>CheckedItems</strong></span> o esaminare l&#8217;elenco utilizzando il metodo <span><strong>GetItemChecked</strong></span> per rilevare gli elementi selezionati. Il metodo <span>GetItemChecked</span> accetta il numero di indice di un elemento come argomento e restituisce <span><span>true</span></span> o <span><span>false</span></span>. <strong>Le proprietà SelectedItems e <span>SelectedIndices</span></strong>, contrariamente a quanto si potrebbe pensare,<strong> non rilevano gli elementi selezionati, ma quelli evidenziati.<br />
Quindi per rilevare gli elementi selezionati in un controllo CheckedListBox :</strong></p>
<ol>
<li>Scorrere l&#8217;insieme <span>CheckedItems</span> partendo da 0, trattandosi di un insieme a base zero. Si noti che il metodo fornirà il numero dell&#8217;elemento nell&#8217;elenco degli elementi selezionati, non nell&#8217;intero elenco. Di conseguenza, se <span id="more-334"></span>il primo elemento dell&#8217;elenco non è selezionato e il secondo sì, nel codice che segue verrà visualizzato un testo analogo a &#8220;Checked Item 1 = MyListItem2&#8243;.</li>
</ol>
<pre class="brush: csharp; title: ; notranslate">
// Determina se ci sono elementi spuntati.
if(checkedListBox1.CheckedItems.Count != 0)
{
// If so, loop through all checked items and print results.
string s = &quot;&quot;;
for(int x = 0; x &lt;= checkedListBox1.CheckedItems.Count - 1 ; x++)
{
s = s + &quot;Checked Item &quot; + (x+1).ToString() + &quot; = &quot;+ checkedListBox1.CheckedItems[x].ToString() + &quot;\n&quot;;
}
MessageBox.Show (s);
}
</pre>
<p>- oppure -</p>
<ol>
<li>Scorrere l&#8217;insieme <span><strong>Items</strong></span> partendo da 0, trattandosi di un insieme a base zero, e chiamare il metodo <span>GetItemChecked</span> per ogni elemento. Tenere presente che questo metodo fornirà il numero dell&#8217;elemento nell&#8217;intero elenco. Di conseguenza, se il primo elemento dell&#8217;elenco non è selezionato e il secondo sì, verrà visualizzato un testo analogo a &#8220;Item 2 = MyListItem2&#8243;.</li>
</ol>
<pre class="brush: csharp; title: ; notranslate">
int i;
strings;
s = &quot;Checked items:\n&quot;;
for(i = 0; i &lt;= (checkedListBox1.Items.Count-1); i++)
{
if(checkedListBox1.GetItemChecked(i))
{
s = s + &quot;Item &quot; + (i+1).ToString() + &quot; = &quot;+ checkedListBox1.Items[i].ToString() + &quot;\n&quot;;
}
}
MessageBox.Show(s);
</pre>
<p><a href="http://www.youbuy.it/lastminute.aspx" rel="nofollow" target="_blank"><img class="aligncenter" title="YouBuy.it - Last Minute - Offerte Sottocosto" src="http://images.youbuy.it/adv/last.jpg" alt="last [C#] Determinare elementi spuntati in un controllo CheckedListBox " width="450" height="600" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.luigimelisi.com/programmazione/net_framework/visual-c/c-determinare-elementi-spuntati-in-un-controllo-checkedlistbox.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

