小菜鸟问一个关于dataGridView的问题
最近小菜鸟我在学c#,很久以前用的是那个VFP,想把一个以前写的vfp程序,改为c#的,也算是边学学做啦
在用到dataGridView的时候,有个问题总是弄不好,
比如有个tyjs.mdb,里面的字段有ftyjsh,fxb,pb等
我在winform 中插入了dataGridView,在调试中,dataGridView也正常表中的数据
可是,我在cellclick 事件中
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
this.textBox1.Text = this.dataGridView1["FTYJSH", this.dataGridView1.CurrentCell.RowIndex].Value.ToString();
this.textBox2.Text = this.dataGridView1["FXB", this.dataGridView1.CurrentCell.RowIndex].Value.ToString();
}
在调试中,不管我选中哪一行,textbox1,和2怎么都是空的,
请问这是怎么一回事
以下是全部的代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“tyjsDataSet.tyjs”中。您可以根据需要移动或删除它。
this.tyjsTableAdapter.Fill(this.tyjsDataSet.tyjs);
}
private void maskedTextBox1_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)
{
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
this.textBox1.Text = this.dataGridView1["FTYJSH", this.dataGridView1.CurrentCell.RowIndex].Value.ToString();
this.textBox2.Text = this.dataGridView1["FXB", this.dataGridView1.CurrentCell.RowIndex].Value.ToString();
}
}
}