DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            OleDbDataAdapter da = new OleDbDataAdapter("select code as 编号,name as 商品名称,dw as 单位 from wl", conn);
            da.Fill(ds);
            dt = ds.Tables[0];
            dataGridView1.DataSource = dt;
单击dataGridView1怎样将当前行的列显示到TEXTBOX中

解决方案 »

  1.   

    对dataGridView1的CellClick事件进行处理就可以了。
      

  2.   

    // 取得当前单元格内容
    Console.WriteLine(DataGridView1.CurrentCell.Value);
    // 取得当前单元格的列 Index
    Console.WriteLine(DataGridView1.CurrentCell.ColumnIndex);
    // 取得当前单元格的行 Index
    Console.WriteLine(DataGridView1.CurrentCell.RowIndex);
      

  3.   

    写datagridview的cellclick事件textbox1.text=dataGridView1[dataGridView1.CurrentCell.ColumnIndex,dataGridView1.CurrentCell.RowIndex].Value