gpt4 book ai didi

c# - 如何显示数据网格中文本框中的所有数据?

转载 作者:行者123 更新时间:2023-11-29 18:03:16 24 4
gpt4 key购买 nike

在所选项目的文本框中显示所有数据的简单方法是什么...例如: enter image description here

如果我点击网站数据,如何在文本框中显示同一沙龙的所有其他数据?

这是我在 MySql 的数据网格中显示数据的方式:

 private void btnShow_Click(object sender, RoutedEventArgs e)
{
string connection = "server=localhost;user id=root; password=root; database=pop-sf40-database";
string query = String.Format("SELECT * FROM salons");

MySqlConnection cn = new MySqlConnection(connection);
cn.Open();

MySqlCommand command = new MySqlCommand(query, cn);
MySqlDataAdapter da = new MySqlDataAdapter(command);

DataTable data = new DataTable();
da.Fill(data);
dgSalons.DataContext = data;
}

最佳答案

我相信这就是你想要的:

// Assumes the DataGrid is bound to a DataTable.
DataTable myTable = (DataTable) dgSalons.DataSource;

txtSample.Text = myTable.Rows[dgSalons.CurrentCell.RowNumber].Cells["Yourcolname"].Value.ToString();

关于c# - 如何显示数据网格中文本框中的所有数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48140138/

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