Reference the form in a function of a class
<p>Here is my code for a <code>CheckXWinner</code> function, where I need to reference my Form in order to draw win lines:</p>

<pre><code>    public void CheckXWinner(Button[] buttonArray, Form1 frm)
    {
        int arrLength = buttonArray.Length; 
        int root = (int)Math.Sqrt(Convert.ToDouble(arrLength));
        bool winner = false;//variable to keep the computer from going when Xwins
        for (int i = 0;  i &lt; root;  i++)
        {
            //Sets the counter for the winners back to zero
            int d2Count = 0;
            int d1Count = 0;
            int hCount = 0;
            int vCount = 0;

                for(int j = 0;  j &lt; root; j++)
                {
                    //increments the appropriate counter if the button contains an X
                    //Horizonal win
                    if (buttonArray[(i*root) + j].Text == "X")
                    {
                        hCount++;
                        if (hCount == root)
                        {
                            for (int z = (root - 1); z &gt;= 0; z--)
                            {
                                buttonArray[(i*root) + z].BackColor = Color.IndianRed;
                            }
                            Xwins();
                            winner = true; //sets winner to true so computer does not take turn 
                        }
                    }//end of Horizonal win

                    //Left to right diagonal
                    if (buttonArray[j + (j*root)].Text == "X")
                    {
                        d1Count++;
                        if (d1Count == root)
                        {
                            for (int z = (root - 1); z &gt;= 0; z--)
                            {
                                buttonArray[z + (z * root)].BackColor = Color.IndianRed;
                            }
                            Xwins();
                            winner = true; 
                        }
                    }//end of LTR win

                    //Right to left diagonal
                    if (buttonArray[(j*(root - 1)) + (root - 1)].Text == "X")
                    {
                        d2Count++;
                        if (d2Count == root)
                        {
                            for (int z = (root - 1); z &gt;= 0; z--)
                            {
                                buttonArray[(z*(root - 1)) + (root - 1)].BackColor = Color.IndianRed;
                            }
                            Xwins();
                            winner = true; 
                        }
                    }//end of RTL win

                    //Vertical win
                    if (buttonArray[i + (root*j)].Text == "X")
                    {
                        vCount++;
                        if (vCount == root)
                        {
                            for (int z = (root - 1); z &gt;= 0; z--)
                            {
                                buttonArray[i + (root*z)].BackColor = Color.IndianRed;
                            }
                            Xwins();
                            winner = true; 
                        }
                    }//end of vert win                        
                }//end of for j loop
        }//end of for loop
        CheckDraw();
        if (winner == false)
        {
            ComputerGoes(buttonArray);
        };

    }//end of CheckXWinner
</code></pre>

<p>In another part of this class I have the handler for all button clicks associated with the form:</p>

<pre><code>    //Handle any button clicks
    private void button_click(object sender, EventArgs e)
    {
        Button b = (Button)sender;
        b.Text = "X";
        b.Enabled = false;
        CheckXWinner(buttonArray, Form1 frm);
    }
</code></pre>

<p>I have errors for the Form1 part of that call, how do I fix this???</p>
