2014-12-09 42 views
0

当我双击DataGridView单元格(行)时,我需要选择并编辑新行中的一行。我到目前为止已经做的是:Datagrdview以新形式编辑

public partial class Vozila : Form 
    { 

     public static int cellValue = 0; 

     public Vozila() 
     { 
      InitializeComponent(); 
     }  

private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) 
     { 
      cellValue = Convert.ToInt32(((DataGridView)sender).SelectedCells[0].Value); 
      DodajVozilo check = new DodajVozilo(); 
      Check.Show(); 
     } 

理念要做到这一点是使用可变cellValue(在DodajVozilo_Load新形式DodajVozilo),并与第 WHERE id=cellValue MySql的SELECT命令,但一个不能得到任何有用的结果。公共静态int变量的WHERE子句语法是什么? 有没有其他想法?

+0

从阅读你的问题,我认为你正在寻找你的SQL查询的where子句是否正确? – Sybren 2014-12-09 12:48:04

回答

0

您在DodajVozilo中描述了一个新变量,例如public int id;

private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) 
     { 
      cellValue = Convert.ToInt32(((DataGridView)sender).SelectedCells[0].Value); 
      DodajVozilo check = new DodajVozilo(); 
     check.id=cellValue; 
      check.Show(); 
     } 

之后你应该用MYSQL中的id进行查询。

+0

再次出现同样的问题。无法查询任何内容。 – 2014-12-09 13:34:06

+0

再次出现同样的问题。无法查询任何内容。 – 2014-12-09 13:34:40

+0

我想看看DodajVozilo_Load。方法。你能告诉我代码吗? – 2014-12-09 14:32:28