- Nov 11, 2009
- 4,364
- 1
- 81
I am doing a project for a C# class I am in and I am having a few issues getting dynamically created buttons to execute a click on them. It is supposed to be a Skyrim perk calculator just as an FYI.
As it stands now this is one of my classes for Archery: http://pastebin.com/Cqifycq7
I create a button for each perk in the tree place them and draw lines connecting them.
Now taking the code for the Overdraw perk.
Now I add in
and it says:
then I add in the actual event for when the button is clicked:
But the code inside the overdraw event never fires when i click the button. I cannot figure out what i am doing wrong here. Any help?
As it stands now this is one of my classes for Archery: http://pastebin.com/Cqifycq7
I create a button for each perk in the tree place them and draw lines connecting them.
Now taking the code for the Overdraw perk.
Code:
Button btnOverdraw = new Button();
btnOverdraw.Location = new Point(582, 442);
btnOverdraw.Text = "Overdraw " + perks[1, 1] + "/5";
btnOverdraw.Size = new System.Drawing.Size(124, 23);
this.Controls.Add(btnOverdraw);
Now I add in
Code:
submitButton.Click += new EventHandler(submitButton_Click);
Code:
Button btnOverdraw = new Button();
btnOverdraw.Location = new Point(582, 442);
btnOverdraw.Text = "Overdraw " + perks[1, 1] + "/5";
btnOverdraw.Size = new System.Drawing.Size(124, 23);
this.Controls.Add(btnOverdraw);
btnOverdraw.Click += new EventHandler(btnOverdraw_Click);
then I add in the actual event for when the button is clicked:
Code:
private void btnOverdraw_Click(object sender, EventArgs e)
{
if (perks[1, 1] < 5)
{
perks[1, 1]++;
}
//blah blah blah
}
But the code inside the overdraw event never fires when i click the button. I cannot figure out what i am doing wrong here. Any help?
