c# - Message Box won't show, and no errors are found. What am I doing wrong? -


i'm trying make application when 2 selections 2 different list boxes match. test put in "messagebox.show("it works!!!"), , although no syntax errors logically it's not working properly.

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms;  namespace distance_converter {     public partial class form1 : form     {         public form1()         {             initializecomponent();         }          private void button1_click(object sender, eventargs e)         {             if (inputlistbox.selectedindex == 0 && outputlistbox.selectedindex == 1)                 messagebox.show("it works!!!");                 }       }  } 

what doing wrong here? i've made sure names correct, can't work.

you're code looks good, must not hooked correctly. 2 posible issues can think of are:

  • your button not hooked event handler. ensure method being executed when button pressed.
  • the index values checking may not expect them be.

i following determine issue:

  1. comment out if statement , see if message displayed.

if not, button not hooked method. if is, there wrong conditions in if statement.

i give code examples on mobile. hope helped!


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -