我要单击DataGrid中某行数据  弹出个 新都窗体 在新的窗体中接受传过来的值,显示到TextBox中 在进行更新 

解决方案 »

  1.   

    新窗口的构造函数定义成有参数的构造函数,用来传递grid的选择行的数据
      

  2.   

    在你要datagridview页面里添加一个public static 的变量Str。当单击的时候 Str=this.datagridview1["所取的列名", count].Value.ToString()
    在你的新打开的页面里可以通过类来引用这个公共的全局变量。这种方法只是其中的一种。页面传值的方法好多,比如:通过类构造方法,以及通过把所要传值页的控件声明为Public,还有控件的跨页面互操作。等等。以下这个贴子可以很通俗的描述了页面间的传值,楼主有空看看吧!
    http://dev.csdn.net/article/26/26433.shtm
      

  3.   

    在你要传值的datagridview页面里添加一个public static 的变量Str。 
      

  4.   

    单击DataGrid中某行时取出数据作为参数,传递给窗体,在窗体显示的时候再显示到TextBox中
    再把在窗体修改好的新值传回DataGrid即可
      

  5.   

     private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
            {
                DataGridViewRow dvr = this.dataGridView1.SelectedRows[0];
                Form2 f2 = null;
               
                     f2 = new Form2(dvr);
                
                f2.Show();        }using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace winappTest
    {
        public partial class Form2 : Form
        {
            DataGridViewRow _dvr = new DataGridViewRow();   
            public Form2()
            {
                InitializeComponent();
            }
            public Form2(DataGridViewRow dvr)
            {
                InitializeComponent();
                _dvr = dvr;
                
                
            }
            private void Form2_Load(object sender, EventArgs e)
            {
                this.label1.Text = _dvr.Cells[1].Value.ToString();
            }
        }
    }思路:双击行的时候把选择行的 DataGridViewRow  作为参数传给 Form2
         
      

  6.   

    DataGridViewRow dvr=this.dataGridView1.SelectedRows[0]; 报错 索引超出范围。必须为非负值并小于集合大小。
    参数名: index
      

  7.   

    你没有选择一行。 this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;  把datagridview的选择方式改下。