Ok, I am trying to to make a double-click action when you click on a cell or row, within a dataGridView. The end goal is to have the single click select the whole row so that when you double-click any cell in the row it will load that row into a separate dataGridView.
I have searched and found this:
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellcontentdoubleclick.aspx
But I cant figure out how to use it, even to just do the messagebox that it includes in it.
Any ideas? This is driving me crazy. I am running a stripped down test program before loading it in my main one. Here is the code for that. It just has a button to open a file browser. A textbox to load the file path into, a button to launch the file data into the first dataGridView, and an extra dataGridView. Thank you for all of your help!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog fdlg = new OpenFileDialog();
fdlg.Title = "C# Corner Open File Dialog";
fdlg.InitialDirectory = @"c:\";
fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*";
fdlg.FilterIndex = 2;
fdlg.RestoreDirectory = true;
if (fdlg.ShowDialog() == DialogResult.OK)
{
string listLocation = fdlg.FileName;
textBox1.Text = fdlg.FileName;
}
}
private void button2_Click(object sender, EventArgs e)
{
dataGridView1.DataSource = null;
XmlDataDocument xmldataHQ = new XmlDataDocument();
xmldataHQ.DataSet.ReadXml(textBox1.Text);
DataSet dsHQ = new DataSet("Stats");
dsHQ = xmldataHQ.DataSet;
dataGridView1.DataSource = dsHQ.DefaultViewManager;
dataGridView1.DataMember = "StatVal";
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}