i have the following code and am trying to retrieve the cursor/mouse position when it is over the drawn array and output it to the lab:
Label[ , ] _arr = new Label[4 , 4];
private void Form1_Load(object sender, EventArgs e)
{
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
_arr[i ,j] = new Label();
_arr[i ,j].Text = ""+i+","+j;
_arr[i ,j].Size = new Size(50,50);
_arr[i ,j].Location = new Point(j*50,i*50); //you can set other property here like Border or else
_arr[i, j].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle ;
this.Controls.Add(_arr[i ,j]);
**label2.Text = _arr[i, j].(System.Windows.Forms.Control.MousePosition).ToString();**
}
}
}
but i am having trouble with the line within double asterisks, can anyone help me resolve this error?
You could try something like this. It might not be the best way to do it, but it gives the desired result of updating the label as the mouse moves between each cell in your “array” on the form: