Why the List Lightnins is all the time empty count 0 ?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
In Form1 i have this in the top of the Form:
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="typ Lightnings_Extractor<span class="pun .<span class="pln PDF pdf1<span class="pun ;
[/code]
Then in the constructor of Form1 i have:
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="pln pdf1 <span class="pun =<span class="pln  <span class="kwd new<span class="pln  <span class="typ Lightnings_Extractor<span class="pun .<span class="pln PDF<span class="pun ();
[/code]
Then in the bottom of Form1 i have:
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="kwd private<span class="pln  <span class="kwd void<span class="pln  deleteSelectedLightningsToolStripMenuItem_Click<span class="pun (<span class="kwd object<span class="pln  sender<span class="pun ,<span class="pln  <span class="typ EventArgs<span class="pln  e<span class="pun )<span class="pln 
            <span class="pun {<span class="pln 

                <span class="kwd if<span class="pln  <span class="pun (<span class="typ MessageBox<span class="pun .<span class="typ Show<span class="pun (<span class="str "Are you Sure you want to delete "<span class="pln  <span class="pun +<span class="pln  <span class="typ Lightnings_Extractor<span class="pun .<span class="typ ListBoxControl<span class="pun .<span class="pln counter <span class="pun +<span class="pln   <span class="str " files ? Click Yes to Confirm and No to continue"<span class="pun ,<span class="pln  <span class="str "WinForm"<span class="pun ,<span class="pln  <span class="typ MessageBoxButtons<span class="pun .<span class="typ YesNo<span class="pun ,<span class="pln  <span class="typ MessageBoxIcon<span class="pun .<span class="typ Question<span class="pun )<span class="pln  <span class="pun ==<span class="pln  <span class="typ DialogResult<span class="pun .<span class="typ No<span class="pun )<span class="pln 
                <span class="pun {<span class="pln 

                <span class="pun }<span class="pln 
                <span class="kwd else<span class="pln 
                <span class="pun {<span class="pln 
                       <span class="kwd for<span class="pln  <span class="pun (<span class="typ int<span class="pln  i <span class="pun =<span class="pln  <span class="lit 0<span class="pun ;<span class="pln  i <span class="pun <<span class="pln  pdf1<span class="pun .<span class="typ Lightnings<span class="pun .<span class="typ Count<span class="pun ;<span class="pln  i<span class="pun ++)<span class="pln 
                        <span class="pun {<span class="pln 

                        <span class="pun }<span class="pln 
                <span class="pun }<span class="pln 
            <span class="pun }
[/code]
And in the PDF class i have:
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="pln using <span class="typ System<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Collections<span class="pun .<span class="typ Generic<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Linq<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Text<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Diagnostics<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="pln IO<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Drawing<span class="pun ;<span class="pln 
using <span class="typ PdfSharp<span class="pun ;<span class="pln 
using <span class="typ PdfSharp<span class="pun .<span class="typ Drawing<span class="pun ;<span class="pln 
using <span class="typ PdfSharp<span class="pun .<span class="typ Pdf<span class="pun ;<span class="pln 
using <span class="typ PdfSharp<span class="pun .<span class="typ Pdf<span class="pun .<span class="pln IO<span class="pun ;<span class="pln 

namespace <span class="typ Lightnings_Extractor<span class="pln 
<span class="pun {<span class="pln 
    <span class="kwd class<span class="pln  PDF
    <span class="pun {<span class="pln 
        <span class="kwd public<span class="pln  <span class="typ List<span class="str <string><span class="pln  <span class="typ Lightnings<span class="pun ;<span class="pln 

        <span class="kwd public<span class="pln  PDF<span class="pun ()<span class="pln  
        <span class="pun {<span class="pln 
            <span class="typ Lightnings<span class="pln  <span class="pun =<span class="pln  <span class="kwd new<span class="pln  <span class="typ List<span class="str <string><span class="pun ();<span class="pln 
        <span class="pun }
[/code]
Now before i click on the: deleteSelectedLightningsToolStripMenuItem_Click <br/>
menu im doing this in another Form:
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="pln using <span class="typ System<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Collections<span class="pun .<span class="typ Generic<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ ComponentModel<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Data<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Drawing<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Drawing<span class="pun .<span class="typ Imaging<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Linq<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Text<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Windows<span class="pun .<span class="typ Forms<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="pln IO<span class="pun ;<span class="pln 
using unfreez_wrapper<span class="pun ;<span class="pln 
using <span class="typ WindowsFormsApplication1<span class="pun ;<span class="pln 
using <span class="typ DannyGeneral<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Text<span class="pun .<span class="typ RegularExpressions<span class="pun ;<span class="pln 
using <span class="typ Extracting_Frames<span class="pun ;<span class="pln 

namespace <span class="typ Lightnings_Extractor<span class="pln 
<span class="pun {<span class="pln 
    <span class="kwd public<span class="pln  <span class="kwd partial<span class="pln  <span class="kwd class<span class="pln  <span class="typ Lightnings_Mode<span class="pln  <span class="pun :<span class="pln  <span class="typ Form<span class="pln 
    <span class="pun {<span class="pln 
        <span class="kwd private<span class="pln  <span class="typ List<span class="str <int><span class="pln  m_itemIndexes <span class="pun =<span class="pln  <span class="kwd new<span class="pln  <span class="typ List<span class="str <int><span class="pun ();<span class="pln 
        <span class="typ Lightnings_Extractor<span class="pun .<span class="pln PDF pdf1<span class="pun ;<span class="pln 
        <span class="kwd public<span class="pln  <span class="kwd static<span class="pln  <span class="kwd string<span class="pln  item<span class="pun ;<span class="pln 
        <span class="typ Form1<span class="pln  f1 <span class="pun =<span class="pln  <span class="kwd null<span class="pun ;<span class="pln 
        <span class="typ List<span class="str <string><span class="pln  recentItems <span class="pun =<span class="pln  <span class="kwd new<span class="pln  <span class="typ List<span class="str <string><span class="pun ();<span class="pln 

        <span class="kwd public<span class="pln  <span class="typ Lightnings_Mode<span class="pun (<span class="typ Form1<span class="pln  f1<span class="pun )<span class="pln 
        <span class="pun {<span class="pln 
            <span class="typ InitializeComponent<span class="pun ();<span class="pln 


            pdf1 <span class="pun =<span class="pln  <span class="kwd new<span class="pln  <span class="typ Lightnings_Extractor<span class="pun .<span class="pln PDF<span class="pun ();<span class="pln 
            <span class="kwd this<span class="pun .<span class="pln f1 <span class="pun =<span class="pln  f1<span class="pun ;<span class="pln 
        <span class="pun }<span class="pln 

        <span class="kwd private<span class="pln  <span class="kwd void<span class="pln  <span class="typ Lightnings_Mode_Load<span class="pun (<span class="kwd object<span class="pln  sender<span class="pun ,<span class="pln  <span class="typ EventArgs<span class="pln  e<span class="pun )<span class="pln 
        <span class="pun {<span class="pln 
            <span class="kwd this<span class="pun .<span class="typ Size<span class="pln  <span class="pun =<span class="pln  <span class="kwd new<span class="pln  <span class="typ Size<span class="pun (<span class="lit 416<span class="pun ,<span class="pln  <span class="lit 506<span class="pun );<span class="pln 
            <span class="kwd this<span class="pun .<span class="typ Location<span class="pln  <span class="pun =<span class="pln  <span class="kwd new<span class="pln  <span class="typ Point<span class="pun (<span class="lit 23<span class="pun ,<span class="pln  <span class="lit 258<span class="pun );<span class="pln 
            listBoxIndexs<span class="pun ();<span class="pln 
            listBoxControl1<span class="pun .<span class="typ MyListBox<span class="pun .<span class="typ SelectedIndex<span class="pln  <span class="pun =<span class="pln  <span class="lit 0<span class="pun ;<span class="pln              listBoxControl1<span class="pun .<span class="typ MyListBox<span class="pun .<span class="typ SelectedIndexChanged<span class="pln  <span class="pun +=<span class="pln  <span class="kwd new<span class="pln  <span class="typ EventHandler<span class="pun (<span class="pln listBox1_SelectedIndexChanged<span class="pun );<span class="pln 
            <span class="kwd this<span class="pun .<span class="pln listBoxControl1<span class="pun .<span class="typ ItemRemoved<span class="pln  <span class="pun +=<span class="pln  <span class="kwd new<span class="pln  <span class="typ EventHandler<span class="pun <<span class="typ ItemEventArgs<span class="pun >(<span class="pln listBoxControl1_ItemRemoved<span class="pun );<span class="pln 
        <span class="pun }<span class="pln 

        <span class="kwd private<span class="pln  <span class="kwd void<span class="pln  listBoxIndexs<span class="pun ()<span class="pln 
        <span class="pun {<span class="pln 
            listBoxControl1<span class="pun .<span class="typ MyListBox<span class="pun .<span class="typ Items<span class="pun .<span class="typ Clear<span class="pun ();<span class="pln 
            listBoxControl1<span class="pun .<span class="typ Dock<span class="pln  <span class="pun =<span class="pln  <span class="typ DockStyle<span class="pun .<span class="typ Fill<span class="pun ;<span class="pln 
            <span class="kwd for<span class="pln  <span class="pun (<span class="typ int<span class="pln  i <span class="pun =<span class="pln  <span class="lit 0<span class="pun ;<span class="pln  i <span class="pun <<span class="pln  <span class="typ Form1<span class="pun .<span class="pln lightningsRegions<span class="pun .<span class="typ Count<span class="pun ;<span class="pln  i<span class="pun ++)<span class="pln 
            <span class="pun {<span class="pln 

                listBoxControl1<span class="pun .<span class="typ MyListBox<span class="pun .<span class="typ Items<span class="pun .<span class="typ Add<span class="pun (<span class="typ Form1<span class="pun .<span class="pln lightningsRegions<span class="pun [<span class="pln i<span class="pun ]);<span class="pln 

            <span class="pun }<span class="pln 
        <span class="pun }<span class="pln 

        <span class="kwd private<span class="pln  <span class="kwd void<span class="pln  listBox1_SelectedIndexChanged<span class="pun (<span class="kwd object<span class="pln  sender<span class="pun ,<span class="pln  <span class="typ System<span class="pun .<span class="typ EventArgs<span class="pln  e<span class="pun )<span class="pln 
        <span class="pun {<span class="pln 
            item <span class="pun =<span class="pln  listBoxControl1<span class="pun .<span class="typ MyListBox<span class="pun .<span class="typ SelectedItem<span class="pun .<span class="typ ToString<span class="pun ();<span class="pln 
            <span class="kwd this<span class="pun .<span class="pln f1<span class="pun .<span class="typ PlayLightnings<span class="pun ();<span class="pln 
            f1<span class="pun .<span class="pln pdftoolsmenu<span class="pun ();<span class="pln 
            <span class="typ int<span class="pln  indx <span class="pun =<span class="pln  listBoxControl1<span class="pun .<span class="typ MyListBox<span class="pun .<span class="typ SelectedIndex<span class="pun ;<span class="pln 
            <span class="kwd if<span class="pln  <span class="pun (<span class="pln listBoxControl1<span class="pun .<span class="typ Indices<span class="pun .<span class="typ Contains<span class="pun (<span class="pln indx<span class="pun ))<span class="pln 
            <span class="pun {<span class="pln 
                <span class="kwd if<span class="pln  <span class="pun (<span class="pln item <span class="pun !=<span class="pln  <span class="kwd null<span class="pln  <span class="pun &&<span class="pln  <span class="pun !<span class="pln pdf1<span class="pun .<span class="typ Lightnings<span class="pun .<span class="typ Contains<span class="pun (<span class="pln item<span class="pun .<span class="typ ToString<span class="pun ()))<span class="pln 
                <span class="pun {<span class="pln 
                    pdf1<span class="pun .<span class="typ Lightnings<span class="pun .<span class="typ Add<span class="pun (<span class="pln item<span class="pun .<span class="typ ToString<span class="pun ());<span class="pln 
                <span class="pun }<span class="pln 
            <span class="pun }<span class="pln 
        <span class="pun }<span class="pln 

        <span class="kwd void<span class="pln  listBoxControl1_ItemRemoved<span class="pun (<span class="kwd object<span class="pln  sender<span class="pun ,<span class="pln  <span class="typ ItemEventArgs<span class="pln  e<span class="pun )<span class="pln 
        <span class="pun {<span class="pln            
            pdf1<span class="pun .<span class="typ Lightnings<span class="pun .<span class="typ Remove<span class="pun (<span class="pln e<span class="pun .<span class="typ Name<span class="pun .<span class="typ ToString<span class="pun ());<span class="pln              <span class="typ Lightnings_Extractor<span class="pun .<span class="typ ListBoxControl<span class="pun .<span class="pln counter <span class="pun =<span class="pln  <span class="typ Lightnings_Extractor<span class="pun .<span class="typ ListBoxControl<span class="pun .<span class="pln counter <span class="pun -<span class="pln  <span class="lit 1<span class="pun ;<span class="pln 

        <span class="pun }<span class="pln 
    <span class="pun }<span class="pln 
<span class="pun }
[/code]
And the listBox User Control i created:
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="com /*----------------------------------------------------------------
 * Module Name  : ListBoxControl
 * Description  : Change listBox items color
 * Author       : Danny
 * Date         : 30/12/2012
 * Revision     : 1.00
 * --------------------------------------------------------------*/<span class="pln 

using <span class="typ System<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Collections<span class="pun .<span class="typ Generic<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ ComponentModel<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Drawing<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Data<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Linq<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Text<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Windows<span class="pun .<span class="typ Forms<span class="pun ;<span class="pln 

<span class="com /*
 *  Introduction :
 * 
 *  By default the color is red.
 *  Added a property to change the color.
 *  Right mouse click on item to change item color.
 *  Left mouse click on item to change the item color back.
 *  If the listBox is empty the control will be filled with 10 "Test" items.
 * */<span class="pln 

namespace <span class="typ Lightnings_Extractor<span class="pln  <span class="com // to check how and change the namespace to listBoxControl<span class="pln 
<span class="pun {<span class="pln 
    <span class="kwd public<span class="pln  <span class="kwd partial<span class="pln  <span class="kwd class<span class="pln  <span class="typ ListBoxControl<span class="pln  <span class="pun :<span class="pln  <span class="typ UserControl<span class="pln 
    <span class="pun {<span class="pln 
        <span class="kwd private<span class="pln  <span class="typ Color<span class="pln  m_MyListColor<span class="pun ;<span class="pln 
        <span class="kwd private<span class="pln  <span class="typ List<span class="str <int><span class="pln  m_itemIndexes <span class="pun =<span class="pln  <span class="kwd new<span class="pln  <span class="typ List<span class="str <int><span class="pun ();<span class="pln 
        <span class="kwd private<span class="pln  <span class="typ List<span class="str <int><span class="pln  m_coloringItemIndexes <span class="pun =<span class="pln  <span class="kwd new<span class="pln  <span class="typ List<span class="str <int><span class="pun ();<span class="pln 
        <span class="kwd public<span class="pln  <span class="kwd static<span class="pln  <span class="typ int<span class="pln  counter<span class="pun ;<span class="pln 
        <span class="kwd public<span class="pln  <span class="kwd event<span class="pln  <span class="typ EventHandler<span class="pun <<span class="typ ItemEventArgs<span class="pun ><span class="pln  <span class="typ ItemRemoved<span class="pun ;<span class="pln 

        <span class="kwd public<span class="pln  <span class="typ List<span class="str <int><span class="pln  <span class="typ Indices<span class="pln 
        <span class="pun {<span class="pln 
            get <span class="pun {<span class="pln  <span class="kwd return<span class="pln  m_itemIndexes<span class="pun ;<span class="pln  <span class="pun }<span class="pln 
        <span class="pun }<span class="pln 

        <span class="kwd public<span class="pln  <span class="typ ListBoxControl<span class="pun ()<span class="pln 
        <span class="pun {<span class="pln 
            <span class="typ InitializeComponent<span class="pun ();<span class="pln 

            counter <span class="pun =<span class="pln  <span class="lit 0<span class="pun ;<span class="pln 
            <span class="kwd if<span class="pln  <span class="pun (<span class="pln listBox1<span class="pun .<span class="typ Items<span class="pun .<span class="typ Count<span class="pln  <span class="pun ==<span class="pln  <span class="lit 0<span class="pun )<span class="pln 
            <span class="pun {<span class="pln 
                <span class="kwd for<span class="pln  <span class="pun (<span class="typ int<span class="pln  i <span class="pun =<span class="pln  <span class="lit 0<span class="pun ;<span class="pln  i <span class="pun <<span class="pln  <span class="lit 10<span class="pun ;<span class="pln  i<span class="pun ++)<span class="pln 
                <span class="pun {<span class="pln 
                    listBox1<span class="pun .<span class="typ Items<span class="pun .<span class="typ Add<span class="pun (<span class="str "Test "<span class="pln  <span class="pun +<span class="pln  i<span class="pun );<span class="pln 
                <span class="pun }<span class="pln 
            <span class="pun }<span class="pln 
        <span class="pun }<span class="pln 

        <span class="kwd private<span class="pln  <span class="kwd void<span class="pln  listBox1_MouseDown<span class="pun (<span class="kwd object<span class="pln  sender<span class="pun ,<span class="pln  <span class="typ MouseEventArgs<span class="pln  e<span class="pun )<span class="pln 
        <span class="pun {<span class="pln 
            <span class="typ int<span class="pln  index <span class="pun =<span class="pln  listBox1<span class="pun .<span class="typ IndexFromPoint<span class="pun (<span class="pln e<span class="pun .<span class="pln X<span class="pun ,<span class="pln  e<span class="pun .<span class="pln Y<span class="pun );<span class="pln 

            <span class="kwd if<span class="pln  <span class="pun (<span class="pln e<span class="pun .<span class="typ Button<span class="pln  <span class="pun ==<span class="pln  <span class="typ System<span class="pun .<span class="typ Windows<span class="pun .<span class="typ Forms<span class="pun .<span class="typ MouseButtons<span class="pun .<span class="typ Right<span class="pun )<span class="pln 
            <span class="pun {<span class="pln 
                <span class="kwd if<span class="pln  <span class="pun (<span class="pln m_itemIndexes<span class="pun .<span class="typ Contains<span class="pun (<span class="pln index<span class="pun ))<span class="pln 
                    <span class="kwd return<span class="pun ;<span class="pln 

                m_itemIndexes<span class="pun .<span class="typ Add<span class="pun (<span class="pln index<span class="pun );<span class="pln 
                <span class="typ DrawItem<span class="pun (<span class="pln index<span class="pun );<span class="pln 
                counter <span class="pun +=<span class="pln  <span class="lit 1<span class="pun ;<span class="pln 
            <span class="pun }<span class="pln 
            <span class="kwd else<span class="pln  <span class="kwd if<span class="pln  <span class="pun (<span class="pln e<span class="pun .<span class="typ Button<span class="pln  <span class="pun ==<span class="pln  <span class="typ MouseButtons<span class="pun .<span class="typ Left<span class="pun )<span class="pln 
            <span class="pun {<span class="pln 
                <span class="kwd if<span class="pln  <span class="pun (!<span class="pln m_itemIndexes<span class="pun .<span class="typ Contains<span class="pun (<span class="pln index<span class="pun ))<span class="pln 
                    <span class="kwd return<span class="pun ;<span class="pln 

                m_itemIndexes<span class="pun .<span class="typ Remove<span class="pun (<span class="pln index<span class="pun );<span class="pln 
                <span class="typ DrawItem<span class="pun (<span class="pln index<span class="pun );<span class="pln 
                <span class="typ OnItemRemoved<span class="pun (<span class="pln index<span class="pun ,<span class="pln  listBox1<span class="pun .<span class="typ Items<span class="pun [<span class="pln index<span class="pun ].<span class="typ ToString<span class="pun ());<span class="pln 
            <span class="pun }<span class="pln   
            listBox1<span class="pun .<span class="typ SelectedIndex<span class="pln  <span class="pun =<span class="pln  index<span class="pun ;<span class="pln 
        <span class="pun }<span class="pln 

        <span class="kwd protected<span class="pln  <span class="kwd virtual<span class="pln  <span class="kwd void<span class="pln  <span class="typ OnItemRemoved<span class="pun (<span class="typ int<span class="pln  indx<span class="pun ,<span class="pln  <span class="kwd string<span class="pln  name<span class="pun )<span class="pln 
        <span class="pun {<span class="pln 
            <span class="typ EventHandler<span class="pun <<span class="typ ItemEventArgs<span class="pun ><span class="pln  handler <span class="pun =<span class="pln  <span class="typ ItemRemoved<span class="pun ;<span class="pln 

            <span class="kwd if<span class="pun (<span class="pln handler <span class="pun !=<span class="pln  <span class="kwd null<span class="pun )<span class="pln 
                <span class="typ ItemRemoved<span class="pun (<span class="kwd this<span class="pun ,<span class="pln  <span class="kwd new<span class="pln  <span class="typ ItemEventArgs<span class="pun ()<span class="pln  <span class="pun {<span class="pln   <span class="typ Index<span class="pln  <span class="pun =<span class="pln  indx<span class="pun ,<span class="pln  <span class="typ Name<span class="pln  <span class="pun =<span class="pln  name<span class="pun });<span class="pln 
        <span class="pun }<span class="pln 

        <span class="kwd private<span class="pln  <span class="kwd void<span class="pln  listBox1_DrawItem<span class="pun (<span class="kwd object<span class="pln  sender<span class="pun ,<span class="pln  <span class="typ DrawItemEventArgs<span class="pln  e<span class="pun )<span class="pln 
        <span class="pun {<span class="pln 
            m_MyListColor <span class="pun =<span class="pln  <span class="typ MyListColor<span class="pun ;<span class="pln 
            <span class="kwd if<span class="pln  <span class="pun (<span class="pln m_MyListColor<span class="pun .<span class="typ IsEmpty<span class="pln  <span class="pun ==<span class="pln  <span class="kwd true<span class="pun )<span class="pln 
            <span class="pun {<span class="pln 
                m_MyListColor <span class="pun =<span class="pln  <span class="typ Color<span class="pun .<span class="typ Red<span class="pun ;<span class="pln 
            <span class="pun }<span class="pln 

            bool selected <span class="pun =<span class="pln  <span class="pun (<span class="pln e<span class="pun .<span class="typ State<span class="pln  <span class="pun &<span class="pln  <span class="typ DrawItemState<span class="pun .<span class="typ Selected<span class="pun )<span class="pln  <span class="pun ==<span class="pln  <span class="typ DrawItemState<span class="pun .<span class="typ Selected<span class="pun ;<span class="pln 

            <span class="kwd if<span class="pln  <span class="pun (<span class="pln m_itemIndexes<span class="pun .<span class="typ Contains<span class="pun (<span class="pln e<span class="pun .<span class="typ Index<span class="pun ))<span class="pln 
            <span class="pun {<span class="pln 
                using <span class="pun (<span class="kwd var<span class="pln  brush <span class="pun =<span class="pln  <span class="kwd new<span class="pln  <span class="typ SolidBrush<span class="pun (<span class="pln m_MyListColor<span class="pun ))<span class="pln 
                <span class="pun {<span class="pln 
                    e<span class="pun .<span class="typ Graphics<span class="pun .<span class="typ FillRectangle<span class="pun (<span class="pln brush<span class="pun ,<span class="pln  e<span class="pun .<span class="typ Bounds<span class="pun );<span class="pln 
                <span class="pun }<span class="pln 
            <span class="pun }<span class="pln 
            <span class="kwd else<span class="pln 
            <span class="pun {<span class="pln 
                e<span class="pun .<span class="typ DrawBackground<span class="pun ();<span class="pln 
            <span class="pun }<span class="pln 

            <span class="kwd string<span class="pln  item <span class="pun =<span class="pln  listBox1<span class="pun .<span class="typ Items<span class="pun [<span class="pln e<span class="pun .<span class="typ Index<span class="pun ].<span class="typ ToString<span class="pun ();<span class="pln 
            e<span class="pun .<span class="typ Graphics<span class="pun .<span class="typ DrawString<span class="pun (<span class="pln item<span class="pun ,<span class="pln  e<span class="pun .<span class="typ Font<span class="pun ,<span class="pln  selected <span class="pun ||<span class="pln  m_itemIndexes<span class="pun .<span class="typ Contains<span class="pun (<span class="pln e<span class="pun .<span class="typ Index<span class="pun )<span class="pln  <span class="pun ?<span class="pln  <span class="typ Brushes<span class="pun .<span class="typ White<span class="pln  <span class="pun :<span class="pln  <span class="typ Brushes<span class="pun .<span class="typ Black<span class="pun ,<span class="pln  e<span class="pun .<span class="typ Bounds<span class="pun ,<span class="pln  <span class="typ StringFormat<span class="pun .<span class="typ GenericDefault<span class="pun );<span class="pln 

            <span class="kwd if<span class="pln  <span class="pun (<span class="pln selected<span class="pun )<span class="pln 
                e<span class="pun .<span class="typ DrawFocusRectangle<span class="pun ();<span class="pln 
        <span class="pun }<span class="pln 

        <span class="kwd private<span class="pln  <span class="kwd void<span class="pln  <span class="typ DrawItem<span class="pun (<span class="typ int<span class="pln  index<span class="pun )<span class="pln 
        <span class="pun {<span class="pln 
            <span class="typ Rectangle<span class="pln  rectItem <span class="pun =<span class="pln  listBox1<span class="pun .<span class="typ GetItemRectangle<span class="pun (<span class="pln index<span class="pun );<span class="pln 
            listBox1<span class="pun .<span class="typ Invalidate<span class="pun (<span class="pln rectItem<span class="pun );<span class="pln 
        <span class="pun }<span class="pln 

        <span class="pun [<span class="typ Browsable<span class="pun (<span class="kwd true<span class="pun )]<span class="pln 
        <span class="kwd public<span class="pln  <span class="typ Color<span class="pln  <span class="typ MyListColor<span class="pln 
        <span class="pun {<span class="pln 
            get <span class="pun {<span class="pln  <span class="kwd return<span class="pln  m_MyListColor<span class="pun ;<span class="pln  <span class="pun }<span class="pln 
            <span class="typ set<span class="pln 
            <span class="pun {<span class="pln 
                m_MyListColor <span class="pun =<span class="pln  value<span class="pun ;<span class="pln 
                <span class="typ Refresh<span class="pun ();<span class="pln 
            <span class="pun }<span class="pln 
        <span class="pun }<span class="pln 

        <span class="pun [<span class="typ Browsable<span class="pun (<span class="kwd true<span class="pun )]<span class="pln 
        <span class="kwd public<span class="pln  <span class="typ ListBox<span class="pln  <span class="typ MyListBox<span class="pln 
        <span class="pun {<span class="pln 
            get <span class="pun {<span class="pln  <span class="kwd return<span class="pln  listBox1<span class="pun ;<span class="pln  <span class="pun }<span class="pln 
            <span class="typ set<span class="pln 
            <span class="pun {<span class="pln 
                listBox1 <span class="pun =<span class="pln  value<span class="pun ;<span class="pln 
                <span class="typ Refresh<span class="pun ();<span class="pln 
            <span class="pun }<span class="pln 
        <span class="pun }<span class="pln 

        <span class="kwd private<span class="pln  <span class="kwd void<span class="pln  <span class="typ ListBoxControl_Load<span class="pun (<span class="kwd object<span class="pln  sender<span class="pun ,<span class="pln  <span class="typ EventArgs<span class="pln  e<span class="pun )<span class="pln 
        <span class="pun {<span class="pln 
            <span class="kwd this<span class="pun .<span class="pln listBox1<span class="pun .<span class="typ SelectedIndex<span class="pln  <span class="pun =<span class="pln  <span class="lit 0<span class="pun ;<span class="pln 
        <span class="pun }<span class="pln 
    <span class="pun }<span class="pln 

    <span class="kwd public<span class="pln  <span class="kwd class<span class="pln  <span class="typ ItemEventArgs<span class="pln  <span class="pun :<span class="pln  <span class="typ EventArgs<span class="pln 
    <span class="pun {<span class="pln 
        <span class="kwd public<span class="pln  <span class="typ int<span class="pln  <span class="typ Index<span class="pln  <span class="pun {<span class="pln  get<span class="pun ;<span class="pln  <span class="typ set<span class="pun ;<span class="pln  <span class="pun }<span class="pln 
        <span class="kwd public<span class="pln  <span class="kwd string<span class="pln  <span class="typ Name<span class="pln  <span class="pun {<span class="pln  get<span class="pun ;<span class="pln  <span class="typ set<span class="pun ;<span class="pln  <span class="pun }<span class="pln 
    <span class="pun }<span class="pln 
<span class="pun }
[/code]
I click on items in the listBox user control right clicks and color the items <br/>
i click on in Red. I used a breakpoint on the New Form :
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="kwd private<span class="pln  <span class="kwd void<span class="pln  listBox1_SelectedIndexChanged<span class="pun (<span class="kwd object<span class="pln  sender<span class="pun ,<span class="pln  <span class="typ System<span class="pun .<span class="typ EventArgs<span class="pln  e<span class="pun )<span class="pln 
        <span class="pun {<span class="pln 
            item <span class="pun =<span class="pln  listBoxControl1<span class="pun .<span class="typ MyListBox<span class="pun .<span class="typ SelectedItem<span class="pun .<span class="typ ToString<span class="pun ();<span class="pln 
            <span class="kwd this<span class="pun .<span class="pln f1<span class="pun .<span class="typ PlayLightnings<span class="pun ();<span class="pln 
            f1<span class="pun .<span class="pln pdftoolsmenu<span class="pun ();<span class="pln 
            <span class="typ int<span class="pln  indx <span class="pun =<span class="pln  listBoxControl1<span class="pun .<span class="typ MyListBox<span class="pun .<span class="typ SelectedIndex<span class="pun ;<span class="pln 
            <span class="kwd if<span class="pln  <span class="pun (<span class="pln listBoxControl1<span class="pun .<span class="typ Indices<span class="pun .<span class="typ Contains<span class="pun (<span class="pln indx<span class="pun ))<span class="pln 
            <span class="pun {<span class="pln 
                <span class="kwd if<span class="pln  <span class="pun (<span class="pln item <span class="pun !=<span class="pln  <span class="kwd null<span class="pln  <span class="pun &&<span class="pln  <span class="pun !<span class="pln pdf1<span class="pun .<span class="typ Lightnings<span class="pun .<span class="typ Contains<span class="pun (<span class="pln item<span class="pun .<span class="typ ToString<span class="pun ()))<span class="pln 
                <span class="pun {<span class="pln 
                    pdf1<span class="pun .<span class="typ Lightnings<span class="pun .<span class="typ Add<span class="pun (<span class="pln item<span class="pun .<span class="typ ToString<span class="pun ());<span class="pln 
                <span class="pun }<span class="pln 
            <span class="pun }<span class="pln 
        <span class="pun }
[/code]
And i see that Lightnings have items inside . But then when i click on the: <br/>
deleteSelectedLightningsToolStripMenuItem_Click in Form1 i see that Lightnings <br/>
is empty count 0. I cant figure out why.

I had the same problem with the variable counter in the listBox User Control wich was 0 also all the time. I cant find out why counter or Lightnings are getting reset or set to be empty . Tried to use breakpoints on all the places i did an instances for
the Lightnings list but when i click on the : deleteSelectedLightningsToolStripMenuItem_Click its never get to any of the instances. Same for counter variable in the listBox User Control used a breakpoint and it never get to the line in the listBox user control
code: counter = 0; so i cant understand where and why this variables get reset all the time. <hr class="sig danieli

View the full article
 
Back
Top