【问题标题】:How to show all data in textbox from datagrid?如何从数据网格中显示文本框中的所有数据?
【发布时间】:2018-01-07 18:12:53
【问题描述】:

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

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

这就是我在 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;
    }

【问题讨论】:

    标签: c# mysql wpfdatagrid


    【解决方案1】:

    我相信这就是你想要的:

    // Assumes the DataGrid is bound to a DataTable.
    DataTable myTable = (DataTable) dgSalons.DataSource;
    
    txtSample.Text = myTable.Rows[dgSalons.CurrentCell.RowNumber].Cells["Yourcolname"].Value.ToString();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-01
      • 2017-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多