获得其他窗体中在datagridview中选中的值

解决方案 »

  1.   

    将其它窗体的datagridview  Modifiers 属性设置成 public 
      

  2.   

    将窗体的datagridview Modifiers 属性设置成 public 了
      int i = dataGrid1.CurrentCell.RowIndex;
                            string user = dataGrid1.Rows[i].Cells[0].Value.ToString();
                            byte[] newpass = Encoding.Default.GetBytes(this.tbxNewPass.Text.Trim());    //tbPass为输入密码的文本框
                            MD5 md5 = new MD5CryptoServiceProvider();
                            byte[] outputPass = md5.ComputeHash(newpass);
                            string md5NewPass = BitConverter.ToString(outputPass); //加密Newpass                        string changePass = "update xx_user set pass=" + "'" + md5NewPass + "'";
                            MySQLCommand q = new MySQLCommand(changePass, conn);
                            q.ExecuteNonQuery();
                            MessageBox.Show("密码修改成功!", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.None);
                            this.Close();显示 错误 1 当前上下文中不存在名称“dataGrid1”