保存获取到DataGridView的坐标

时间:2014-06-23 11:41:09

标签: c# winforms datagridview

我有一个项目,我必须通过鼠标点击获取正在运行的视频的坐标,这是我已经拥有的。

现在我必须通过将列头设为X和Y来保存DataGridView中的坐标。这是获取坐标的代码。

请给我其他代码或帮助我理解,因为我是c#的初学者。

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();
    }

0 个答案:

没有答案