110,533
社区成员
发帖
与我相关
我的任务
分享
//子窗体
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//添加了一个属性
public DataGridViewCell DGVCell
{
get;
set;
}
private void Form1_Load(object sender, EventArgs e)
{
//Form1 上就是一个TextBox1,一个Button1
}
private void button1_Click(object sender, EventArgs e)
{
if (DGVCell != null)
{
DGVCell.Value = textBox1.Text;
}
this.Close();
}
}
--------------------------------------------
//主窗体
private void MenuEdit_Click(object sender, EventArgs e)
{
DataGridViewCell cell = this.dataGridView1.CurrentCell; //得到当前选择的DataGridVIew的单元格
Form1 f = new Form1();
f.DGVCell = cell;
f.ShowDialog();
}
//................不知道适不适合你.....
public partial class Form1 : Form
{
private Form2 form2;
public Form1()
{
InitializeComponent();
DataTable one = new DataTable();
one.Columns.Add("one");
one.Columns.Add("two");
one.Rows.Add("1", "2");
one.Rows.Add("3", "4");
this.dataGridView1.DataSource = one;
form2 = new Form2();
}
private void button1_Click(object sender, EventArgs e)
{
form2.ShowDialog();
}
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}