gpt4 book ai didi

c# - Datagridview 以新形式编辑

转载 作者:行者123 更新时间:2023-11-29 23:20:17 25 4
gpt4 key购买 nike

当我双击 DataGridView 单元格(行)时,我需要在新表单中选择并编辑该行。到目前为止我所做的是:

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 )并使用 MySql SELECT 命令 with 子句WHERE id=cellValue 但无法获得任何可用的结果。带有 public static int 变量的 WHERE 子句语法是什么?还有其他想法吗?

最佳答案

您在 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进行查询。

关于c# - Datagridview 以新形式编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27379095/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com