C# 将获得的坐标保存到DataGridView中
我有一个项目,在这个项目中,我必须通过鼠标点击获得正在运行的视频的坐标,我已经得到了 现在我必须通过将列标题设置为X和Y,将坐标保存在DataGridView中。下面是获取坐标的代码 请给我其他的代码或者帮助我理解,因为我是c语言的初学者C# 将获得的坐标保存到DataGridView中,c#,winforms,datagridview,C#,Winforms,Datagridview,我有一个项目,在这个项目中,我必须通过鼠标点击获得正在运行的视频的坐标,我已经得到了 现在我必须通过将列标题设置为X和Y,将坐标保存在DataGridView中。下面是获取坐标的代码 请给我其他的代码或者帮助我理解,因为我是c语言的初学者 public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button2_Click(
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog openfileialog1 = new OpenFileDialog();
if (openfileialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.textBox_Path.Text = openfileialog1.FileName;
}
}
private void button1_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = textBox_Path.Text;
axWindowsMediaPlayer1.Ctlcontrols.play();
}
private void button3_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.Ctlcontrols.stop();
}
private void button4_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.Ctlcontrols.pause() ;
}
int x = 0, y = 0;
protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);
Pen P = new Pen(Color.DarkSeaGreen);
Pen erase = new Pen(Color.White);
x = e.X; y = e.Y;
}
private void axWindowsMediaPlayer1_ClickEvent(object sender, AxWMPLib._WMPOCXEvents_ClickEvent e)
{
int x = 0, y = 0;
Pen P = new Pen(Color.DarkSeaGreen);
Pen erase = new Pen(Color.White);
x = e.fX; y = e.fY;
label1.Location = new Point(x - label1.Width, y);
label2.Location = new Point(x, y - label2.Height);
label1.Text = x.ToString();
label2.Text = y.ToString();
}
是否要在DataGridView中绑定所有捕获的X和Y?是否可以在设计时或运行时创建DGV?你的问题到底是什么,获取坐标还是将它们放入DGV?我的意思是,当我点击视频时,它应该显示坐标并保存在DGV中。是的,我想绑定所有捕获的X和Y。每次单击坐标时,它也可以保存在excel中