Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


List Box Issues


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Phil_93   Members   -  Reputation: 146

Like
0Likes
Like

Posted 18 August 2012 - 08:58 AM

Hey I've ran into another issue where I don't know what's going on. I'm still following the tutorials I mentioned in a previous post. I'm making a small program that uses for loops to cycle through numbers. I am using a listbox to display the numbers when the program is executed. I have followed the tutorial as it stated but I'm getting an error when I try to run my program.

My code is as follows, as well as the error message that appears:

private void button1_Click(object sender, EventArgs e)
{
int loopStart;
int loopEnd;
int answer = 0;
loopStart = int.Parse(textBox1.Text);
loopEnd = int.Parse(textBox2.Text);
for (int i = loopStart; i > loopEnd; i++)
{
answer = answer + i;
listBox1.Items.Add(answer.ToString());
}

When I run it I get this:

Error 1 'Loops.Form1' does not contain a definition for 'listBox1_SelectedIndexChanged' and no extension method 'listBox1_SelectedIndexChanged' accepting a first argument of type 'Loops.Form1' could be found (are you missing a using directive or an assembly reference?)

I really have no idea what's happening I will attachAttached File  Loops.zip   36.93KB   32 downloads my program to this post. Any help is greatly appreciated :)

Sponsor:

#2 lwm   Members   -  Reputation: 1448

Like
1Likes
Like

Posted 18 August 2012 - 11:19 AM

The error occurs in this line in the "Form1.Designer.cs" file:
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);

I'm guessing you registered a handler for the SelectedIndexChanged event in the designer at one point but deleted the automatically-generated method in the "Form1.cs" file. The code-behind file generated by the designer still tries to use the missing method however. You can simply double-click on the error message and delete the line to get rid of the error.

current project: Roa


#3 Phil_93   Members   -  Reputation: 146

Like
0Likes
Like

Posted 18 August 2012 - 11:50 AM

Thank you for the help :) I feel stupid not knowing what half of this stuff is/means D:




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS