<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=48&amp;t=5301&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2013-12-29T15:07:28+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=48&amp;t=5301&amp;mode</id>
<entry>
<author><name><![CDATA[xamrex]]></name></author>
<updated>2013-12-29T15:07:28+01:00</updated>
<published>2013-12-29T15:07:28+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62732#p62732</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62732#p62732"/>
<title type="html"><![CDATA[Re: c# Listbox i wartość pola]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62732#p62732"><![CDATA[
Dzięki panowie <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":-)" title="Szczęśliwy" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=74">xamrex</a> — 29 gru 2013, o 15:07</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[OdeOn]]></name></author>
<updated>2013-12-28T22:35:15+01:00</updated>
<published>2013-12-28T22:35:15+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62655#p62655</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62655#p62655"/>
<title type="html"><![CDATA[Re: c# Listbox i wartość pola]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62655#p62655"><![CDATA[
Możesz dodać taką linijke ułatwi wybieranie.<br />[syntax=csharp]// Changes the selection mode from double-click to single click.<br />checkedListBox1.CheckOnClick = true;[/syntax]<br /><br />W całości coś takiego może też zadziałać:<br /><br />[syntax=csharp]using System;<br />using System.Collections.Generic;<br />using System.ComponentModel;<br />using System.Data;<br />using System.Drawing;<br />using System.Linq;<br />using System.Text;<br />using System.Windows.Forms;<br /><br />namespace tetty<br />{<br /><br />    public partial class Form1 : Form<br />    {<br />        public Form1()<br />        {<br />            InitializeComponent();<br /><br />            KolanaItems item1 = new KolanaItems();<br />            KolanaItems item2 = new KolanaItems();<br />            KolanaItems item3 = new KolanaItems();<br /><br />            item1.Text = &quot;1200mm&quot;;<br />            item1.Value = 1200;<br />            item2.Text = &quot;1000mm&quot;;<br />            item2.Value = 1000;<br />            item3.Text = &quot;800mm&quot;;<br />            item3.Value = 800;<br /><br />            checkedListBox1.Items.Add(item1);<br />            checkedListBox1.Items.Add(item2);<br />            checkedListBox1.Items.Add(item3);<br />           <br />            // Changes the selection mode from double-click to single click.<br />            checkedListBox1.CheckOnClick = true;  <br />        }<br /><br />        private void button1_Click(object sender, EventArgs e)<br />        {<br />            //to wyświetlało zaznaczenie czyli to co ma niebieskie tło<br />            //MessageBox.Show((checkedListBox1.SelectedItem as KolanaItems).Value.ToString());<br />    decimal wynik=0;<br /><br />    foreach(int i in checkedListBox1.CheckedIndices)<br />    {<br />       switch (i)<br />        {<br />        case 0:<br />        if (numericUpDown1.Value &gt; 0)<br />        {<br />        wynik += decimal.Parse((numericUpDown1.Text)) * (decimal.Parse(((KolanaItems)checkedListBox1.Items&#91;i&#93;).Value.ToString())/1000);<br />        }<br />        break;<br />        case 1:<br />        if (numericUpDown2.Value &gt; 0)<br />        {<br />        wynik += decimal.Parse((numericUpDown2.Text)) * (decimal.Parse(((KolanaItems)checkedListBox1.Items&#91;i&#93;).Value.ToString())/1000);<br />        }<br />        break;<br />        case 2:<br />        if (numericUpDown3.Value &gt; 0)<br />        {<br />        wynik += decimal.Parse((numericUpDown3.Text)) * (decimal.Parse(((KolanaItems)checkedListBox1.Items&#91;i&#93;).Value.ToString())/1000);<br />        }<br />        break;<br />         }<br />    }<br />    MessageBox.Show(&quot;wynik &quot; + wynik.ToString());<br />        }<br />   <br />    public class KolanaItems<br />    {<br />        public string Text { get; set; }<br />        public object Value { get; set; }<br /><br />        public override string ToString()<br />        {<br />            return Text;<br />        }<br />    }<br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1407">OdeOn</a> — 28 gru 2013, o 22:35</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[vaffanculo]]></name></author>
<updated>2013-12-28T19:12:58+01:00</updated>
<published>2013-12-28T19:12:58+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62598#p62598</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62598#p62598"/>
<title type="html"><![CDATA[Re: c# Listbox i wartość pola]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62598#p62598"><![CDATA[
To może pod zdarzenie button1_Click wrzuć coś takiego:<br /><br />[syntax=csharp]private void button1_Click(object sender, EventArgs e)<br />        {<br />            decimal val = 0;<br />            foreach (object itemChecked in checkedListBox1.CheckedItems)<br />            {<br /><br />                if (itemChecked.ToString() == item1.Text)<br />                {<br />                 <br />                    val += numericUpDown1.Value * decimal.Parse(item1.Value.ToString());<br />                }<br /><br />                if (itemChecked.ToString() == item2.Text)<br />                {<br />                    val += numericUpDown2.Value * decimal.Parse( item2.Value.ToString());<br />                }<br /><br />                if (itemChecked.ToString() == item3.Text)<br />                {<br />                 <br />                    val += numericUpDown3.Value * decimal.Parse(item3.Value.ToString());<br />                }<br /><br />            }<br /><br /><br />            MessageBox.Show(val.ToString());<br /><br />        }[/syntax]<br /><br />Edit<br /><br />Zapomniałem dodać że musisz przenieść deklaracje obiektów twojej klasy KolanaItems aby były widoczne globalnie<br /><br />[syntax=csharp]namespace tetty<br />{<br /><br />    public partial class Form1 : Form<br />    {<br /><br />        KolanaItems item1 = new KolanaItems();<br />        KolanaItems item2 = new KolanaItems();<br />        KolanaItems item3 = new KolanaItems();[/syntax]<br /><br />Możesz też zastosować coś takiego<br /><br />[syntax=csharp]private void button1_Click(object sender, EventArgs e)<br />        {<br />            decimal val = 0;<br />            foreach (object itemChecked in checkedListBox1.CheckedItems)<br />            {<br /><br />                if (itemChecked.ToString() == ((KolanaItems)checkedListBox1.Items&#91;0&#93;).Text)<br />                {<br />                    val += numericUpDown1.Value * decimal.Parse(((KolanaItems)checkedListBox1.Items&#91;0&#93;).Value.ToString());<br />                                }<br /><br />                if (itemChecked.ToString() == ((KolanaItems)checkedListBox1.Items&#91;1&#93;).Text)<br />                {<br />                    val += numericUpDown2.Value * decimal.Parse(((KolanaItems)checkedListBox1.Items&#91;1&#93;).Value.ToString());<br />                }<br /><br />                if (itemChecked.ToString() == ((KolanaItems)checkedListBox1.Items&#91;2&#93;).Text)<br />                {<br /><br />                    val += numericUpDown3.Value * decimal.Parse(((KolanaItems)checkedListBox1.Items&#91;2&#93;).Value.ToString());<br />                }<br /><br />            }<br /><br />            MessageBox.Show(val.ToString());<br />        }[/syntax]<br /><br />W tym przypadku resztę kodu możesz pozostawić bez zmian<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1784">vaffanculo</a> — 28 gru 2013, o 19:12</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xamrex]]></name></author>
<updated>2013-12-28T16:10:49+01:00</updated>
<published>2013-12-28T16:10:49+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62576#p62576</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62576#p62576"/>
<title type="html"><![CDATA[Re: c# Listbox i wartość pola]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62576#p62576"><![CDATA[
Już myślałem, że pójdzie z górki, a tu dalej lipa<br />Zrobiłem sobie coś takiego:<br />[syntax=csharp]using System;<br />using System.Collections.Generic;<br />using System.ComponentModel;<br />using System.Data;<br />using System.Drawing;<br />using System.Linq;<br />using System.Text;<br />using System.Windows.Forms;<br /><br />namespace tetty<br />{<br /><br />    public partial class Form1 : Form<br />    {<br />        public Form1()<br />        {<br />            InitializeComponent();<br /><br />            KolanaItems item1 = new KolanaItems();<br />            KolanaItems item2 = new KolanaItems();<br />            KolanaItems item3 = new KolanaItems();<br /><br />            item1.Text = &quot;1200mm&quot;;<br />            item1.Value = 1200;<br />            item2.Text = &quot;1000mm&quot;;<br />            item2.Value = 1000;<br />            item3.Text = &quot;800mm&quot;;<br />            item3.Value = 800;<br /><br />            checkedListBox1.Items.Add(item1);<br />            checkedListBox1.Items.Add(item2);<br />            checkedListBox1.Items.Add(item3);<br />  <br />        }<br /><br />        private void button1_Click(object sender, EventArgs e)<br />        {<br />            MessageBox.Show((checkedListBox1.SelectedItem as KolanaItems).Value.ToString());<br />        }<br />    }<br />    public class KolanaItems<br />    {<br />        public string Text { get; set; }<br />        public object Value { get; set; }<br /><br />        public override string ToString()<br />        {<br />            return Text;<br />        }<br />    }<br />}[/syntax]<br /><br />I teraz działa, ale tylko gdy zaznaczę jednego checkboxa<br />A gdy zaznaczę więcej, to zwracany jest tylko pierwszy.<br />Co muszę poprawić w kodzie?<br /><br />Zaznaczony TYLKO 1200(działa)<br /><a href="http://forum.atnel.pl/_obrazki/o/74/80953f04dd8222374992065d58f9bbb9.PNG"  class="postlink"><img src="http://forum.atnel.pl/_obrazki/o/74/80953f04dd8222374992065d58f9bbb9.PNG" alt="Obrazek" /></a><br /><br />Zaznaczony TYLKO 800(działa)<br /><a href="http://forum.atnel.pl/_obrazki/o/74/d274abf9f25e87b1099469ab1ae07e0f.PNG"  class="postlink"><img src="http://forum.atnel.pl/_obrazki/o/74/d274abf9f25e87b1099469ab1ae07e0f.PNG" alt="Obrazek" /></a><br /><br />Zaznaczone oba (NIE działa)<br /><a href="http://forum.atnel.pl/_obrazki/o/74/948125250455366bb606e73255d606b3.PNG"  class="postlink"><img src="http://forum.atnel.pl/_obrazki/o/74/948125250455366bb606e73255d606b3.PNG" alt="Obrazek" /></a><br /><br />Nadałem wartość wentylatorom (czyli ten 1200, ma wartość 1200, 1000 ma wartość 1000 itp)<br />Chcę teraz aby po kliknięciu na button policzył się wzór że mnoży zaznaczony wentylator razy ilość (która się wybiera z NumericUpDown)<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=74">xamrex</a> — 28 gru 2013, o 16:10</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Jaglarz]]></name></author>
<updated>2013-12-28T14:42:16+01:00</updated>
<published>2013-12-28T14:42:16+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62565#p62565</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62565#p62565"/>
<title type="html"><![CDATA[Re: c# Listbox i wartość pola]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62565#p62565"><![CDATA[
Musisz odczytać czy wartość bodajże Checked jest true czy false.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=471">Jaglarz</a> — 28 gru 2013, o 14:42</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xamrex]]></name></author>
<updated>2013-12-28T14:03:18+01:00</updated>
<published>2013-12-28T14:03:18+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62564#p62564</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62564#p62564"/>
<title type="html"><![CDATA[c# Listbox i wartość pola]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=5301&amp;p=62564#p62564"><![CDATA[
Witam,<br />Męczę się z jedną rzeczą:<br />Mianowicie zrobiłem sobie list boxa (w którym wybieramy, jakich użyliśmy wentylatorów)<br />A pod spodem zrobiłem NumericUpDown w którym wybieramy ile tych wentylatorów użyliśmy<br /><a href="http://forum.atnel.pl/_obrazki/o/74/12daeca212e77c8cf2940fd7ef5f8ab7.png"  class="postlink"><img src="http://forum.atnel.pl/_obrazki/o/thumb/74/12daeca212e77c8cf2940fd7ef5f8ab7.png" alt="Obrazek" /></a><br />Program służy do obliczania pewnej wartości..<br />I teraz wentylator 1200 ma współczynnik 1,2<br />Wentylator 1000 ma współczynnik 1,0<br />Wentylator 800 ma współczynnik 0,8<br /><br />I teraz nasz wzór to współczynnik tego wentylatora pomnożony razy ilość wentylatorów.<br /><br />W jaki spsób mogę 'nadać' tym &quot;itemom&quot; (wentylator 1200 wartość 1,2) ? żebym mógł łatwo wyliczyć ten wzór?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=74">xamrex</a> — 28 gru 2013, o 14:03</p><hr />
]]></content>
</entry>
</feed>