如何datagrid
在行双击时获取列名的单元格值,而不是项目数组索引?
我生成带有查询的列:
private void grid_supplier_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (grid_supplier.SelectedItem == null) return;
DataRowView dr = grid_supplier.SelectedItem as DataRowView;
DataRow dr1 = dr.Row;
txt_hiden_edit_id.Text = Convert.ToString(dr1.ItemArray[0]);
comb_supplier_name.SelectedValue = Convert.ToString(dr1.ItemArray[1]);
datepicker_supplier.SelectedDate = DateTime.Parse(Convert.ToString(dr1.ItemArray[2]));
txt_payment.Text = Convert.ToString(dr1.ItemArray[3]);
txt_reciept_number.Text = Convert.ToString(dr1.ItemArray[4]);
txt_quantity.Text = Convert.ToString(dr1.ItemArray[5]);
txt_code.Text = Convert.ToString(dr1.ItemArray[6]);
}