Sam

Sam

  • NA
  • 6
  • 0

access a passed parameter

Nov 19 2008 10:17 AM

I have a parent form which passes an array of Creature classes to the child form. I can access the passed classes (crt) from the main form code, but not from the button event. Sorry if this doesn't make sense...basically I need to access crt variable from the button click event. The following code is from the child, or dialog, form. The Creature[] array passes just fine, but not into the button click. Any help would be appreciated!! Sam

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace Game

{

public partial class Battle : Form

{

public Battle(Creature[] crt)

{

InitializeComponent();

int count = crt.Count();

for (int i = 0; i < count; i++)

{

if (count > 1)

{

comboBox1.Items.Add(crt[i].Name + " " + Convert.ToString(i + 1));

}

else

{

comboBox1.Items.Add(crt[i].Name);

}

}

comboBox1.SelectedIndex = 0;

}

private void button1_Click(object sender, EventArgs e)

{

Encounter.PlayerMeleeAttack(crt);

}

}

}


Answers (2)