日期:2014-05-18  浏览次数:20813 次

有关VS 2003 代码和VS2005代码的问题
请问一下 在VS2003的代码
  private void button2_Click(object sender, System.EventArgs e)
{
if (dataGrid1[dataGrid1.CurrentCell]!=null)
{ //ModifySpecialty是我建的一个FOMR
modifyspecialty=new ModifySpecialty();
modifyspecialty.Tag=ds.Tables[0].Rows[dataGrid1.CurrentRowIndex][0].ToString().Trim();
modifyspecialty.textBox1.Text=ds.Tables[0].Rows[dataGrid1.CurrentRowIndex][1].ToString().Trim();
modifyspecialty.textBox2.Text=ds.Tables[0].Rows[dataGrid1.CurrentRowIndex][2].ToString().Trim();
modifyspecialty.ShowDialog();
}
}
在VS2005里面 一些东西改了 比如dataGrid改成了dataGridView 等等,我不知道怎么把上述的代码写成VS2005可以识别的.我把他改为
  private void button1_Click(object sender, EventArgs e)
  {
  if (dataGridView1[dataGridView1.CurrentCell] != null)//问题1:"this"方法没有采用"1"个参数的重载 {
  Form3 form3 = new Form3();
  form3.Tag = ds.Tables[0].Rows[dataGridView1.CurrentRow][0].ToString().Trim();//问题2:与“System.Data.DataRowCollection.this[int]”最匹配的重载方法具有一些无效参数  
  form3.textBox1.Text = ds.Tables[0].Rows[dataGridView1.CurrentRow][1].ToString().Trim();//问题3:“tzj.Form3.textBox1”不可访问,因为它受保护级别限制  
  form3.textBox2.Text = ds.Tables[0].Rows[dataGridView1.CurrentRow][2].ToString().Trim();//问题4:参数“1”: 无法从“System.Windows.Forms.DataGridViewRow”转换为“int”
  form3.ShowDialog();
  }
  }
出现了问题不知道怎么解决.请大家帮一下忙. 我刚学C# 对很多知识都不了解,上述出的问题,是我哪一方面的不足,麻烦大家指点迷津.


------解决方案--------------------
你需要掌握delegate的相关知识。你的实现思路有问题
首先,你得弄清楚变量的范围、变量与控件的区别