解决方案 »

  1.   

    子窗体代码        private void btnOK_Click(object sender, EventArgs e)
            {
                string mysql = "";
                mysql = "update YWPOI set NAME='"+txtNAME.Text+"'";
                OleDbDataAdapter dataAdapter = new OleDbDataAdapter(mysql, DBHelper.conn2);
                this.DialogResult = DialogResult.OK;        }        private void button1_Click(object sender, EventArgs e)
            {
                this.DialogResult = DialogResult.Cancel;
            }
      

  2.   


    objectid是主键问题,双击一行,没有弹出子窗口,无论选中哪一行,我点击button3时,都提示“请先选择一条记录”。
      

  3.   

    if (e.ColumnIndex == 0)//这里决定了你必须双击第一列才行,双击其他列就直接退出方法了
    if (dgv.Rows[e.RowIndex].Cells[1].Value != null)这里决定了你第二列必须有值,如果是null,那么就退出方法了这种问题,自己断点调试一下应该很容易能发现才对
      

  4.   

    frm.ShowDialog();//显示子窗口
     
                //给输出参数赋值默认值
                outNAME = NAME;
     
                //判断是否进行修改数据
                myresult = frm.DialogResult;
    这里,应该
    myresult=frm.ShowDialog();
    ShowDialog方法本身有返回值,返回值类型就是DialogResult,不用费2遍事
      

  5.   

    if (selectrowindex < 0)
    这里,你判断的是个全局变量啊,你确定它有被重新赋值过?为什么不用gdv.SelectedRows来判断呢
      

  6.   

    dgv.Rows[e.RowIndex].Cells[1].Value  取的是 SHAPE的值,当然是空了。 条件根本不成立。
      

  7.   

    改成dgv.Rows[e.RowIndex].Cells[3].Value  点击button3提示超出索引
      

  8.   


    楼主何必拐这么大的弯呢。DataGridView本身就有提供当前行的属性呀dataGridView1.CurrentRow 是当前行
    dataGridView1.CurrentCell  当前选中的单元格
    dataGridView1.CurrentCell.OwenRow 当前单元格所有的行
    private void button3_Click_1(object sender, EventArgs e)
            {
                if (dataGridView1.CurrentRow==null)  
                {
                    MessageBox.Show("请先选择一条记录");
                    return;
                }
             
                if (dataGridView1.CurrentRow.Cells[1].Value != null)
                {
                    //输入参数
                    string NAME =dataGridView1.CurrentRow.Cells[3].Value.ToString();
     
                    //输出参数
                    string outNAME;
     
                    //返回弹出窗口关闭状态
                    DialogResult myresult;
                    this.ShowDialogForm(NAME, out outNAME, out myresult);
                    //如果修改了数据,把当前datagridview内容的对应值进行修改
                    if (myresult == DialogResult.OK)
                    {
                       dataGridView1.CurrentRow.Cells[3].Value = outNAME;
                    }
     
     
                }
            }
      

  9.   

    //获取当前选择的目标
            private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
            {
                selectrowindex = e.RowIndex;
            }接上面的 这个可以不用了。
      

  10.   

    改成dgv.Rows[e.RowIndex].Cells[3].Value  点击button3提示超出索引
    button3里哪来的e.RowIndex