The solution is so simple because you have practically written the solution in that code snippet already, unless I am missing something that you haven't explained.
Here, where you did this:
foreach (Point p in points)
{
e.Graphics.FillEllipse(Brushes.Red,
new Rectangle(p.X - 2, p.Y - 2, 4, 4));
}
Can't you just create a function called
UpdateTextbox()
, like this?
void UpdateTextbox()
{
exampletextbox.Text = "";
foreach (Point p in points)
{
exampletextbox.Text += p.ToString();
}
}
You can customize the way that you represent the coodinates, but really this code is not that different from what you have already.
points
is defined globally, so you can use it in this function. All you need to do is call
UpdateTextbox()
at an appropriate moment, say in
pictureBox1_MouseDown
.