title: Listbox.selected index change variable assignment
body: <p>Hi there
  What is the correct way of assigning the selected index's value from a listbox to a variable? The user selects an item in a listbox and then the output changes depending on their selection.</p>
  
  <p>I use:</p>
  
  <pre><code>variablename = listbox.text
  </code></pre>
  
  <p>in the <code>listBox_SelectedIndexChanged</code> event and this works.   </p>
  
  <p>When I use the <code>button_click</code> event I use:</p>
  
  <pre><code>variablename = listbox.selectedindex 
  </code></pre>
  
  <p>But this does not work in the <code>listbox_selectedindexchanged</code> event.</p>
  
  <p>Please could you let me know if it is okay to use it like I did above or if I will run into problems and why you cannot use the selectedindex method.</p>
  
  <p>Thanks!</p>